Remember one time Netty version conflict, report java.lang.NoSuchMethodError:io.netty.util.internal.ObjectUtil.checkPositive problem

Source: Internet
Author: User

Elasticsearch using Transportclient to initialize thrown exception in 5.6

In the Transportclient package that introduces elasticsearch5.6, Netty is introduced to communicate.

<!--transport client--><dependency><groupid>org.elasticsearch.client</groupid>< Artifactid>transport</artifactid><version>5.6.1</version><exclusions><exclusion ><groupid>commons-logging</groupid><artifactid>commons-logging</artifactid></ Exclusion></exclusions></dependency>

As the project will use the ROCKETMQ,ROCKETMQ will also be self-contained Netty

<dependency><groupid>org.apache.rocketmq</groupid><artifactid>rocketmq-client</ Artifactid><version>4.0.0-incubating</version></dependency>

Start with jetty no problem, but with Tomcat error: java.lang.NoSuchMethodError:io.netty.util.internal.ObjectUtil.checkPositive

It seems that the tomcat handling package conflict is not jetty good

Can be in the project Pom file directory, through the MVN dependency:tree command, view the dependencies between packages, by looking at the method in the package, found that ROCKETMQ comes with the Netty package does not have this method, the Nettty version of ES

Less than the Netty version in ROCKETMQ.

Note: mvn dependency:tree-dverbose-dincludes=asm:asm Similar commands can be found for duplicate jar package references

Workaround:

1. Direct reference to netty4.13 in POM

         <dependency>            <groupId>io.netty</groupId>            <artifactid>netty-all</artifactid >            <version>4.1.13.Final</version>        </dependency>

After introducing the jar above, the conflict is resolved.

2. Add before initializing the Transportclient method

Set environment variables to solve Netty of ES and Netty service itself.
System.setproperty ("Es.set.netty.runtime.available.processors", "false");

The second method did not try, but it should be done.

These are the problems and the solutions.

--------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------

PS: Later in the initialization of the transportclient process, error:

Java.lang.IllegalStateException:availableProcessors is already set to [4], rejecting [4]

Java.lang.IllegalStateException:availableProcessors is already set to [4], rejecting [4]
At Io.netty.util.nettyruntime$availableprocessorsholder.setavailableprocessors (NettyRuntime.java:51)
At Io.netty.util.NettyRuntime.setAvailableProcessors (nettyruntime.java:87)
At Org.elasticsearch.transport.netty4.Netty4Utils.setAvailableProcessors (netty4utils.java:87)
At Org.elasticsearch.transport.netty4.netty4transport.<init> (netty4transport.java:115)
At Org.elasticsearch.transport.netty4plugin.lambda$gettransports$0 (netty4plugin.java:84)
At Org.elasticsearch.client.transport.TransportClient.buildTemplate (transportclient.java:176)
At Org.elasticsearch.client.transport.transportclient.<init> (transportclient.java:262)
At Org.elasticsearch.transport.client.prebuilttransportclient.<init> (prebuilttransportclient.java:128)

Workaround:

Precede initialization with System.setproperty ("Es.set.netty.runtime.available.processors", "false");

Finally, the problem is solved.

Remember one time Netty version conflict, report java.lang.NoSuchMethodError:io.netty.util.internal.ObjectUtil.checkPositive problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.