Elasticsearch 2.0 NoClassDefFoundError for JsonXContentGenerator

Hello, I am trying to update my elasticsearch java client api version from 1.4.2 to 2.0.0. But when I use:

XContentBuilder builder = XContentFactory.jsonBuilder()

It used to work in 1.4.2 but I get this exception in 2.0.0:

Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.common.xcontent.json.JsonXContentGenerator
at org.elasticsearch.common.xcontent.json.JsonXContent.newXContentGenerator(JsonXContent.java:69) ~[elasticsearch-2.0.0.jar:2.0.0]
at org.elasticsearch.common.xcontent.json.JsonXContent.createGenerator(JsonXContent.java:74) ~[elasticsearch-2.0.0.jar:2.0.0]
at org.elasticsearch.common.xcontent.json.JsonXContent.createGenerator(JsonXContent.java:80) ~[elasticsearch-2.0.0.jar:2.0.0]
at org.elasticsearch.common.xcontent.XContentBuilder.<init>(XContentBuilder.java:112) ~[elasticsearch-2.0.0.jar:2.0.0]
at org.elasticsearch.common.xcontent.XContentBuilder.<init>(XContentBuilder.java:102) ~[elasticsearch-2.0.0.jar:2.0.0]
at org.elasticsearch.common.xcontent.XContentBuilder.builder(XContentBuilder.java:80) ~[elasticsearch-2.0.0.jar:2.0.0]
at org.elasticsearch.common.xcontent.json.JsonXContent.contentBuilder(JsonXContent.java:40) ~[elasticsearch-2.0.0.jar:2.0.0]
at org.elasticsearch.common.xcontent.XContentFactory.contentBuilder(XContentFactory.java:122) ~[elasticsearch-2.0.0.jar:2.0.0]
at org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder(XContentFactory.java:49) ~[elasticsearch-2.0.0.jar:2.0.0]

In pom.xml:

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

Thank you

check this solution out :

1 Like