I'm using the java client 7.17.6, with gradle to build the project;
Gradle grabs all of the required dependencies including the org.elasticsearch:elasticsearch:7.17.6.
Using the XContent component throws this stacktrace;
Caused by: java.lang.NoClassDefFoundError: org/apache/lucene/util/Version
I can see the package "org.apache.lucene.util" does indeed exist in the org.elasticsearch:elasticsearch:7.17.6 jar, but not the "Version" class.
Is there another dependency the documentation hasn't mentioned I should be including?
Why are you adding this line?
I'm transitioning from the rest client where we are using the XContent component, my easiest first step is to simply switch out the client transport from REST to Java client.
Therefore for now I still need the XContent.
Oh and I do already have databind on the classpath.
I wonder how the org.elasticsearch:elasticsearch:7.17.6 jar compiles?
Line 67 of org.elasticsearch.common.xcontent.XContentElasticsearchExtension in that jar file;
writers.put(org.apache.lucene.util.Version.class, (b, v) -> b.value(Objects.toString(v)));
References a "org.apache.lucene.util.Version" class that doesn't appear to exist in the list of dependencies for that project.
Ok, so lucene-core is required for compilation which I can see in Maven, so that answers how this compiles.
Perhaps I just can't use XContent with the Java client without having to specify additional dependencies?
Including lucene-core:8.11.1 seems to have gotten me over the hump for anyone else who happens to be doing anything like this in future. Whether this is the right thing to do or not, I don't know.
Don't use anymore elasticsearch server internal classes like XContent.
You should switch totally to the new client instead. One of the goal of the new client is to get rid of the Lucene dependencies
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.