java.lang.NoClassDefFoundError: org/elasticsearch/transport/TcpChannel


(Ankur Singla) #1

I am using 6.1.1 version of elastic but while building TransportClient using PreBuiltTransportClient this error comes up.

Settings settings = Settings.builder()
					.put("cluster.name", "abcdef").build();
			TransportClient client = new PreBuiltTransportClient(settings)
					.addTransportAddress(new TransportAddress(InetAddress.getByName("xxxx.xx-xx-xx"), 1234))
					;

			BulkRequestBuilder bulkRequest = client.prepareBulk();

If there is something that i am doing wrong please let me know.


(Ryan Ernst) #2

What build tool do you use? How are you gathering the transport client jar and its transitive dependencies?


(Muhammad Naeem Akhtar) #3

Hello I am also having the same issue almost, Some time i get java.lang.NoClassDefFoundError (With different class name) and some time java.lang.NoSuchFieldError: LUCENE_6_0_0

My code is below, It breaks on time of build new transport client.

TransportClient client = null;
final Settings settings = Settings.builder().put("cluster.name", CLUSTER_NAME).build();
if (client == null) {
client = new PreBuiltTransportClient(settings)
.addTransportAddress(new TransportAddress(InetAddress.getByName(host), port));

    }

I am using maven as build tool and my POM entry for elasticsearch is

   <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>transport</artifactId>
        <version>6.1.0</version>
    </dependency>

Any one help is most appreciated as i spend whole day on this issue and totally stuck on it.

Thanks


(Muhammad Naeem Akhtar) #4

My complete stack trace is as follow

UT005023: Exception handling request to /api/inbox/index/vorgang: org.jboss.resteasy.spi.UnhandledException: java.lang.NoSuchFieldError: LUCENE_6_0_0
at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:76)
at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:212)
at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:168)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:411)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:202)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
at de.init.commons.webapp.system.ssl.MarkSecureHandler.handleRequest(MarkSecureHandler.java:164)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:284)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoSuchFieldError: LUCENE_6_0_0
at org.elasticsearch.Version.(Version.java:44)
at org.elasticsearch.common.io.stream.StreamOutput.(StreamOutput.java:76)
at org.elasticsearch.common.io.stream.BytesStream.(BytesStream.java:24)
at org.elasticsearch.common.io.stream.BytesStreamOutput.(BytesStreamOutput.java:59)
at org.elasticsearch.common.io.stream.BytesStreamOutput.(BytesStreamOutput.java:56)
at org.elasticsearch.common.io.stream.BytesStreamOutput.(BytesStreamOutput.java:46)
at org.elasticsearch.common.xcontent.XContentBuilder.builder(XContentBuilder.java:69)
at org.elasticsearch.common.settings.Setting.arrayToParsableString(Setting.java:1130)
at org.elasticsearch.common.settings.Setting.access$600(Setting.java:84)
at org.elasticsearch.common.settings.Setting$ListSetting.lambda$new$0(Setting.java:835)
at org.elasticsearch.common.settings.Setting$ListSetting.getRaw(Setting.java:843)
at org.elasticsearch.common.settings.Setting.lambda$listSetting$29(Setting.java:1094)
at org.elasticsearch.common.settings.Setting.listSetting(Setting.java:1099)
at org.elasticsearch.common.settings.Setting.listSetting(Setting.java:1094)
at org.elasticsearch.transport.TcpTransport.(TcpTransport.java:130)
at org.elasticsearch.client.transport.TransportClient.newPluginService(TransportClient.java:98)
at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:128)
at org.elasticsearch.client.transport.TransportClient.(TransportClient.java:262)
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:128)
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:114)
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:104)
at de.init.commons.webapp.features.app_inbox.InboxAPI.createIndex(InboxAPI.java:490)
at de.init.commons.webapp.features.app_inbox.InboxAPI.indexVorgang(InboxAPI.java:449)
at


(Ryan Ernst) #5

@dearnomi Does your application also depend on Lucene directly? This could happen if you have jarhell, and an older version of Lucene is "winning" in the race to be loaded.


(Muhammad Naeem Akhtar) #6

Thanks Ryan, No there is no direct lucene dependency, i clean my project and even removed lucene from .m2 directory.


(Ryan Ernst) #7

Can you run mvn dependency:tree on your project?


(Muhammad Naeem Akhtar) #8

My project's complete dependency tree is too large and cant paste here, i am posting here only the elastic part here

+- org.elasticsearch.client:transport:jar:6.1.0:compile
| +- org.elasticsearch:elasticsearch:jar:6.1.0:compile
| | +- org.apache.lucene:lucene-core:jar:7.1.0:compile
| | +- org.apache.lucene:lucene-analyzers-common:jar:7.1.0:compile
| | +- org.apache.lucene:lucene-backward-codecs:jar:7.1.0:compile
| | +- org.apache.lucene:lucene-grouping:jar:7.1.0:compile
| | +- org.apache.lucene:lucene-highlighter:jar:7.1.0:compile
| | +- org.apache.lucene:lucene-join:jar:7.1.0:compile
| | +- org.apache.lucene:lucene-memory:jar:7.1.0:compile
| | +- org.apache.lucene:lucene-misc:jar:7.1.0:compile
| | +- org.apache.lucene:lucene-queries:jar:7.1.0:compile
| | +- org.apache.lucene:lucene-queryparser:jar:7.1.0:compile
| | +- org.apache.lucene:lucene-sandbox:jar:7.1.0:compile
| | +- org.apache.lucene:lucene-spatial:jar:7.1.0:compile
| | +- org.apache.lucene:lucene-spatial-extras:jar:7.1.0:compile
| | +- org.apache.lucene:lucene-spatial3d:jar:7.1.0:compile
| | +- org.apache.lucene:lucene-suggest:jar:7.1.0:compile
| | +- org.elasticsearch:securesm:jar:1.2:compile
| | +- org.elasticsearch:elasticsearch-cli:jar:6.1.0:compile
| | +- com.carrotsearch:hppc:jar:0.7.1:compile
| | +- org.yaml:snakeyaml:jar:1.17:compile
| | +- com.fasterxml.jackson.dataformat:jackson-dataformat-smile:jar:2.8.10:compile
| | +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.8.10:compile
| | +- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.8.10:compile
| | +- com.tdunning:t-digest:jar:3.0:compile
| | +- org.hdrhistogram:HdrHistogram:jar:2.1.9:compile
| | +- org.apache.logging.log4j:log4j-api:jar:2.9.1:compile
| | - org.elasticsearch:jna:jar:4.4.0-1:compile
| +- org.elasticsearch.plugin:transport-netty4-client:jar:6.1.0:compile
| | +- io.netty:netty-buffer:jar:4.1.13.Final:compile
| | +- io.netty:netty-codec:jar:4.1.13.Final:compile
| | +- io.netty:netty-codec-http:jar:4.1.13.Final:compile
| | +- io.netty:netty-common:jar:4.1.13.Final:compile
| | +- io.netty:netty-handler:jar:4.1.13.Final:compile
| | +- io.netty:netty-resolver:jar:4.1.13.Final:compile
| | - io.netty:netty-transport:jar:4.1.13.Final:compile
| +- org.elasticsearch.plugin:reindex-client:jar:6.1.0:compile
| | - org.elasticsearch.client:elasticsearch-rest-client:jar:6.1.0:compile
| | +- org.apache.httpcomponents:httpasyncclient:jar:4.1.2:compile
| | - org.apache.httpcomponents:httpcore-nio:jar:4.4.5:compile
| +- org.elasticsearch.plugin:lang-mustache-client:jar:6.1.0:compile
| | - com.github.spullara.mustache.java:compiler:jar:0.9.3:compile
| +- org.elasticsearch.plugin:percolator-client:jar:6.1.0:compile
| | - org.elasticsearch.plugin:mapper-extras:jar:6.1.0:compile
| - org.elasticsearch.plugin:parent-join-client:jar:6.1.0:compile

i verified that in complete tree there is no where Lucene included.


(Muhammad Naeem Akhtar) #9

Is this can be maven shade issue? I seen on some discussion

I also followed as per but could not figured out the solution.


(Ankur Singla) #10

I am using maven

> <dependency>
>             <groupId>org.elasticsearch.client</groupId>
>             <artifactId>elasticsearch-rest-high-level-client</artifactId>
>             <version>6.0.1</version>
>     </dependency>
> 
> <dependency>
>     <groupId>org.elasticsearch.client</groupId>
>     <artifactId>transport</artifactId>
>     <version>6.1.1</version>
> </dependency>

Blockquote


(Ankur Singla) #11

Got the issue it was conflicting with restclient version thanks for the response @rjernst


(Ryan Ernst) #12

If you are shading and building an uber jar, then yes, that could be your issue.


(system) #13

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.