Elasticsearch 2.0 NoClassDefFoundError for JsonXContentGenerator [英] Elasticsearch 2.0 NoClassDefFoundError for JsonXContentGenerator

查看:621
本文介绍了Elasticsearch 2.0 NoClassDefFoundError for JsonXContentGenerator的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的elasticsearch java客户端api版本从1.4.2更新为2.0.0。我使用java 1.8。我使用这个代码:

I am trying to update my elasticsearch java client api version from 1.4.2 to 2.0.0. I am using java 1.8 .I use this code:

   XContentBuilder builder = XContentFactory.jsonBuilder()

它曾在1.4.2中工作,但在2.0.0中收到此异常:

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]

pom.xml:

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


推荐答案

原因是我没有com.fasterxml.jackson .core在我的依赖列表中,所以这是导致

The reason is I didnt have com.fasterxml.jackson.core in my dependency list, so this was causing

        java.lang.ClassNotFoundException: com.fasterxml.jackson.core.util.DefaultIndenter

我将其添加到我的pom.xml中:

I added this into my pom.xml:

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.6.3</version>
        </dependency>

解决问题

这篇关于Elasticsearch 2.0 NoClassDefFoundError for JsonXContentGenerator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆