Solved :Java High Level RestClient 6.1.3 NoClassDefFoundError

Hi,
I'm trying to create a very simple Rest Client, as described in the docs.
I'm using maven with this dependency:

<dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-high-level-client</artifactId>
        <version>6.1.3</version>
   </dependency>

RestClientBuilder builder = RestClient.builder(
            new HttpHost("localhost", 9200, "http"));
RestHighLevelClient client = new RestHighLevelClient(builder);

But I get this error:

    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/lucene/util/Version
	    at org.elasticsearch.Version.<clinit>(Version.java:44)
       ...

The org.apache.lucene.util.Version seems to be no longer part of the lucene-core dependency.

What can I do to solve this?

Cheers
Christian

UPDATE: it turned out, that the local maven repos has some problems fetching the lucene jar, so that it was empty...

Hi!

I'm getting the exact same error, but I'm not using Maven (which I know very little about), and I manually get the JARs I need (the ones in the documentation :https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.1/java-rest-high-getting-started-dependencies.html and https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.1/java-rest-low-usage-dependencies.html)

But obviously, at least one is missing. Which one is it or how can I know this? Where can I find it?

Thanks!

PS:
If useful, I added the following JARs :
-elasticsearch
-elasticsearch-transport
-elasticsearch-rest-client
-elasticsearch-rest-high-level-client
-elasticsearch-rest-high-level-client-sniffer (All the five are 6.1.3)

-apache's httpasyncclient 4.1.3
-httpclient 4.5.5
-httpcore 4.4.9
-httpcore-nio 4.4.9

-commons-codec 1.9
-commons-logging 1.2

I ended up using Maven, of course.

Piece of advice for those who want to do a small project like me and not use Maven: use Maven. "elasticsearch-rest-high-level-client" is recursively relying on 60 or 70 dependencies. Maven (or Gradle) handles everything.

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