Reputation: 1
I try to create document via high level rest client with:
Map<String, Object> jsonMap = new HashMap<>();
jsonMap.put("name", "Bob");
jsonMap.put("id", "123456");
IndexRequest indexRequest = new IndexRequest("lead").id("123456").source(jsonMap);
client.index(indexRequest, RequestOptions.DEFAULT);
But it throws a NoClassDefFoundError: org/apache/lucene/util/BytesRefIterator. The elastic version is 7.3.2. That's the elasticsearch dependency in my pom.
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
The full stacktrace:
Exception in thread "Thread-20" java.lang.NoClassDefFoundError: org/apache/lucene/util/BytesRefIterator
at org.elasticsearch.action.index.IndexRequest.source(IndexRequest.java:397)
at org.elasticsearch.action.index.IndexRequest.source(IndexRequest.java:377)
at org.elasticsearch.action.index.IndexRequest.source(IndexRequest.java:365)
at com.sunyard.mdhome.elasticsearch.impl.MetadataDocumentBuilderImpl.createDocument(MetadataDocumentBuilderImpl.java:182)
at com.sunyard.mdhome.elasticsearch.impl.MetadataDocumentBuilderImpl.build(MetadataDocumentBuilderImpl.java:76)
at com.sunyard.mdhome.elasticsearch.impl.MetadataDocumentBuilderImpl.getPage(MetadataDocumentBuilderImpl.java:163)
at com.sunyard.mdhome.elasticsearch.impl.MetadataDocumentBuilderImpl.getSyncMetadata(MetadataDocumentBuilderImpl.java:121)
at com.sunyard.mdhome.thread.MetadataSyncThread.run(MetadataSyncThread.java:30)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.util.BytesRefIterator
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 9 more
The maven dependencies tree: maven dependencies tree 01 maven dependencies tree 02
Upvotes: 0
Views: 504
Reputation: 1
I've found out the cause of the error. There's another dependence in this project which includes a 3.5.0 version of lucene-core.jar
. It conflicts with the 8.1.0 version lucene-core.jar
in elasticsearch. The program uses the 3.5.0 version actually while the program is running.
Upvotes: 0