I am using the following code to create a client on Elasticsearch:
Settings settings = Settings.builder()
.put("cluster.name", "myClusterName")
.build();
TransportClient client = new PreBuiltTransportClient(settings)
.addTransportAddress(newInetSocketTransportAddress(InetAddress.getByName("127.0.0.1"), 9300));
I am getting these errors:
Exception in thread "main" java.lang.NoClassDefFoundError: org/elasticsearch/plugins/ActionPlugin
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<clinit>(PreBuiltTransportClient.java:54)
at exadatum.com.exadatum.elastic.testSearch.main(testSearch.java:30)
Caused by: java.lang.ClassNotFoundException: org.elasticsearch.plugins.ActionPlugin
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 14 more
Update: this is now documented at
Make sure the client dependency has been added to the class path:
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>5.0.0-rc1</version>
</dependency>
This dependency may not be loading transitively from child dependencies.
You may also find that the main Elasticsearch and Apache Logging artifacts need to be on the class path as well:
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>5.0.0-rc1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
</dependency>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With