Netty dependency issue with ElasticSearch 6.3.2

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Netty dependency issue with ElasticSearch 6.3.2



I'm using spring boot and trying to connect with Elasticsearch recent version 6.3.2 but couldn't Do we need to specify any appropriate jar version



Error:


Caused by: java.lang.NoClassDefFoundError: io/netty/util/internal/logging/InternalLoggerFactory
at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_161]
at java.lang.ClassLoader.defineClass(Unknown Source) ~[na:1.8.0_161]
at java.security.SecureClassLoader.defineClass(Unknown Source) ~[na:1.8.0_161]
at java.net.URLClassLoader.defineClass(Unknown Source) ~[na:1.8.0_161]
at java.net.URLClassLoader.access$100(Unknown Source) ~[na:1.8.0_161]
at java.net.URLClassLoader$1.run(Unknown Source) ~[na:1.8.0_161]
at java.net.URLClassLoader$1.run(Unknown Source) ~[na:1.8.0_161]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_161]
at java.net.URLClassLoader.findClass(Unknown Source) ~[na:1.8.0_161]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_161]
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) ~[na:1.8.0_161]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_161]
at org.elasticsearch.transport.netty4.Netty4Utils.<clinit>(Netty4Utils.java:49) ~[transport-netty4-client-6.3.2.jar:6.3.2]
at org.elasticsearch.transport.Netty4Plugin.<clinit>(Netty4Plugin.java:48) ~[transport-netty4-client-6.3.2.jar:6.3.2]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_161]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[na:1.8.0_161]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[na:1.8.0_161]
at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[na:1.8.0_161]
at org.elasticsearch.plugins.PluginsService.loadPlugin(PluginsService.java:696) ~[elasticsearch-6.3.2.jar:6.3.2]
at org.elasticsearch.plugins.PluginsService.<init>(PluginsService.java:114) ~[elasticsearch-6.3.2.jar:6.3.2]
at org.elasticsearch.client.transport.TransportClient.newPluginService(TransportClient.java:107) ~[elasticsearch-6.3.2.jar:6.3.2]
at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:132) ~[elasticsearch-6.3.2.jar:6.3.2]
at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:280) ~[elasticsearch-6.3.2.jar:6.3.2]
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:128) ~[transport-6.3.2.jar:6.3.2]
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:114) ~[transport-6.3.2.jar:6.3.2]
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:104) ~[transport-6.3.2.jar:6.3.2]
at com.techprimers.elastic.standaloneelasticexample.resource.UsersResource.<init>(UsersResource.java:32) ~[classes/:na]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_161]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[na:1.8.0_161]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[na:1.8.0_161]
at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[na:1.8.0_161]
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:170) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
... 19 common frames omitted
Caused by: java.lang.ClassNotFoundException: io.netty.util.internal.logging.InternalLoggerFactory
at java.net.URLClassLoader.findClass(Unknown Source) ~[na:1.8.0_161]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_161]
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) ~[na:1.8.0_161]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_161]
... 51 common frames omitted



The Java Code:


TransportClient client;

public UsersResource() throws UnknownHostException
client = new PreBuiltTransportClient(Settings.EMPTY)
.addTransportAddress(new TransportAddress(InetAddress.getByName("localhost"), 9300));
//client.close();




Below I have given configuration of POM


<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.elastic</groupId>
<artifactId>standalone-elastic-example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>standalone-elastic-example</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<elasticsearch.version>6.3.2</elasticsearch.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
</dependency>
</dependencies>





Did I miss any dependency ?



What causing this issue not able to connect. Kindly let me know in case of any further information.



Thanks in Advance.




1 Answer
1



This might not solve your NoClassDefFoundError but you should probably start using "Java High Level REST Client" since elasticsearch is planning to deprecate the TransportClient in Elasticsearch 7.0 and removing it completely in 8.0.So, it's better to use Java High Level REST Client instead of transport client.



More details are available here.





Thanks for this good info, but currently I'm using version 6 right then this issue should not come right
– Arun
Aug 24 at 7:34






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS