1

I've just asked another question since I was facing some ClassNotFoundException.

Caused by: java.lang.ClassNotFoundException: org.elasticsearch.plugins.NetworkPlugin
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_131]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_131]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) ~[na:1.8.0_131]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_131]
    ... 56 common frames omitted

It's been pointed out to me that this exception means that the mentioned class is not found in the classpath at runtime. This is in the case that I have the container package in the pom.xml file.

<dependency>
    <groupId>org.elasticsearch</groupId>
    <artifactId>elasticsearch</artifactId>
    <version>5.5.0</version>
</dependency>

So now my question is, how can a package be named as a dependency but some class in it be missing at runtime? And also, mvn dependency:tree -Dverbose -Dincludes=commons-collections returns no conflict.

This is a Spring Boot project that I'm running using IntelliJ Idea in debug mode. I'm also using a dozen other packages in my code in the exact same way and they all work smoothly. But as soon as I add Elasticsearch, I face the mentioned exception.

Mehran
  • 15,593
  • 27
  • 122
  • 221

4 Answers4

1

Can you try deleting the downloaded dependency from your computer.

It is located at ~/.m2/repository/org/elasticsearch Assuming you keep maven dependencies in default location and running on a Mac OS X

rm -rf ~/.m2/repository/org/elasticsearch/*

Afterwards try re-downloading the dependency using

mvn dependency:resolve
XPLOT1ON
  • 2,994
  • 2
  • 20
  • 36
0

you can try use one bellow version elasticsearch` of dependency. you can try one dependency from bellow dependencies :-

<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>5.4.3</version>
</dependency>

or

<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>6.0.0-alpha2</version>
</dependency>
Anshul Sharma
  • 3,432
  • 1
  • 12
  • 17
0

Did you try clean and build?, because sometimes when you add a dependency to your pom.xml you will see that the library is downloading but if you try to execute your project without build it you get that error.

Ivan Lynch
  • 563
  • 5
  • 23
0

You've missed the plugin part.

<!-- https://mvnrepository.com/artifact/org.elasticsearch.plugin/plugins -->
<dependency>
    <groupId>org.elasticsearch.plugin</groupId>
    <artifactId>plugins</artifactId>
    <version>2.4.5</version>
    <type>pom</type>
</dependency>

Maybe you also need the transport part:

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

See if this link helps: Elasticsearch TransportClient NetworkPlugin NoClassDefFoundError

JFPicard
  • 5,029
  • 3
  • 19
  • 43