NoClassDefFoundError InternalLoggerFactory on tomcat start

My project was using a very old version of elasticsearch (1.7.1). I am trying to upgrade it to 6.4.0

Following are the jars I added newly.
elasticsearch-6.4.0.jar
elasticsearch-core-6.4.0.jar
elasticsearch-x-content-6.4.0.jar
transport-6.4.0.jar
transport-netty4-client-6.4.0.jar
log4j-api-2.11.0.jar
log4j-core-2.11.0.jar
lucene-core-7.4.0.jar
reindex-client-6.4.0.jar
percolator-client-6.4.0.jar
lang-mustache-client-6.4.0.jar
parent-join-client-6.4.0.jar
rank-eval-client-6.4.0.jar
hppc-0.8.1.jar

During my tomcat start I am getting this exception

java.lang.NoClassDefFoundError: io/netty/util/internal/logging/InternalLoggerFactory
at org.elasticsearch.transport.Netty4Plugin.(Netty4Plugin.java:48)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.elasticsearch.plugins.PluginsService.loadPlugin(PluginsService.java:602)
at org.elasticsearch.plugins.PluginsService.(PluginsService.java:112)
at org.elasticsearch.client.transport.TransportClient.newPluginService(TransportClient.java:108)
at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:133)
at org.elasticsearch.client.transport.TransportClient.(TransportClient.java:283)
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 com.virima.indexing.IndexUtils.initializeESConnection(IndexUtils.java:61)

And my initilization code is as below

Settings settings = Settings.builder()
.put("cluster.name", "myClusterName").build();
TransportClient client = new PreBuiltTransportClient(settings)
.addTransportAddress(new TransportAddress(InetAddress.getByName("host1"), 9300))
.addTransportAddress(new TransportAddress(InetAddress.getByName("host2"), 9300));

See https://www.elastic.co/blog/elasticsearch-the-server

I went through the blog, I am sorry but I dint understand how it helps me in this

Apologies, I assumed you were trying to start a full elasticsearch service inside Tomcat rather than just the elasticsearch client.

We are evolving Java clients away from use of the TransportClient so that we can reduce these sorts of dependencies on core elasticsearch server classes.
The High Level Rest Client is the new replacement for the TransportClient and the docs for managing dependencies are here.

Thanks for the response. So you are suggesting me using REST Client will be better than debugging this with TransportClient?

It will put you on the right path. Transport client will be deprecated in 7.0

I am using high level rest client now, I have lucene 7.1 in my classpath, but I am getting the following error

Exception in thread "main" java.lang.NoSuchFieldError: LUCENE_6_0_0
at org.elasticsearch.Version.(Version.java:47)
at org.elasticsearch.common.io.stream.StreamInput.(StreamInput.java:111)
at org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper.(BytesReference.java:242)
at org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper.(BytesReference.java:236)
at org.elasticsearch.common.bytes.BytesReference.streamInput(BytesReference.java:76)
at org.elasticsearch.action.admin.indices.create.CreateIndexRequest.innerToXContent(CreateIndexRequest.java:554)
at org.elasticsearch.action.admin.indices.create.CreateIndexRequest.toXContent(CreateIndexRequest.java:542)

Looks like your Lucene version is incorrect.

Dependecy file says Lucene-core 7.4.0, that only I added

If your classpath is setup correctly and you don't have other Lucene versions floating around then the above error should not happen because you should see this

Hi, that issue seems to be fine, Any help on this How to add multiple types to an index Elasticsearch 6.4

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