Alexandre S.
Alexandre S.

Reputation: 540

NoClassDefFoundError using elasticsearch in Java

I want to use elasticsearch in my java application but when I try to connect to my Node, i had the following error

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/lucene/util/Version

So I install the lucene librairie (version 6.5.1) And I still the error. I'm a beginner with elasticsearch so please tell me if I forgot a step

Upvotes: 2

Views: 2010

Answers (1)

RoshanKumar Mutha
RoshanKumar Mutha

Reputation: 2445

As mentioned by Mocky in this answer:

This is caused when there is a class file that your code depends on and it is present at compile time but not found at runtime. Look for differences in your build time and runtime classpaths.

So, if using maven then add,

<dependency>
   <groupId>org.apache.lucene</groupId>
   <artifactId>lucene-core</artifactId>
   <version>3.6.0</version>
</dependency>

if using gradle,

// https://mvnrepository.com/artifact/org.apache.lucene/lucene-core

compile group: 'org.apache.lucene', name: 'lucene-core', version: '3.6.0'

Upvotes: 2

Related Questions