简体   繁体   English

错误:java.lang.NoSuchFieldError:LUCENE_5_2_1

[英]Erro: java.lang.NoSuchFieldError: LUCENE_5_2_1

Am trying to Index to elastic search using java API and later use that data for visualisation in Kibana as below:我正在尝试使用 java API 索引弹性搜索,然后使用该数据在 Kibana 中进行可视化,如下所示:

package elasticSearchTest;

import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import java.net.InetAddress;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.testng.annotations.Test;

public class ES_Test_Class {
  @Test
  public void f() {
  try{
      Client client = TransportClient.builder().build()
               .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));


      IndexResponse response = client.prepareIndex("twitter", "tweet", "1")
                .setSource(jsonBuilder()
                            .startObject()
                                .field("user", "kimchy")
                                .field("postDate", "18/May/2011:01:48:10")
                                .field("message", "trying out Elasticsearch")
                            .endObject()
                          )
                .get();
    // Document ID (generated or not)
      String _id = response.getId();
    // Version (if it's the first time you index this document, you will get: 1)
    long _version = response.getVersion();

    System.out.println("Document id is: "+_id);

    System.out.println("Document version is: "+_version);
      }
      catch (Exception e){
          e.printStackTrace();
      }

  }
}

Below are the updated dependencies:以下是更新的依赖项:

在此处输入图片说明

However when I run the code I get below error:但是,当我运行代码时,出现以下错误:

[TestNG] Running: C:\\Users\\vinbhask\\AppData\\Local\\Temp\\testng-eclipse--931338640\\testng-customsuite.xml Nov 04, 2016 9:03:52 PM org.elasticsearch.plugins.PluginsService INFO: [Kismet] modules [], plugins [], sites [] FAILED: f java.lang.NoSuchFieldError: LUCENE_5_2_1 at org.elasticsearch.Version.(Version.java:265) at org.elasticsearch.client.transport.TransportClient$Builder.build(TransportClient.java:129) at elasticSearchTest.ES_Test_Class.f(ES_Test_Class.java:17) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84) at org.testng.internal.Invoker.invokeMethod(Invoker.java:714) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901) at org.testng.internal.Inv [TestNG] 运行:C:\\Users\\vinbhask\\AppData\\Local\\Temp\\testng-eclipse--931338640\\testng-customsuite.xml 2016 年 11 月 4 日晚上 9:03:52 org.elasticsearch.plugins.PluginsService INFO:[ Kismet] 模块 []、插件 []、站点 [] 失败:f java.lang.NoSuchFieldError: LUCENE_5_2_1 在 org.elasticsearch.Version.(Version.java:265) 在 org.elasticsearch.client.transport.TransportClient$Builder。 build(TransportClient.java:129) at elasticSearchTest.ES_Test_Class.f(ES_Test_Class.java:17) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun .reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84) at org. testng.internal.Invoker.invokeMethod(Invoker.java:714) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901) at org.testng.internal.Inv oker.invokeTestMethods(Invoker.java:1231) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) oker.invokeTestMethods(Invoker.java:1231) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)

I tried googling for the solution and came across this link and this link but could not understand how to resolve the issue, I had even rebuilt the project by adding one JAR at a time but of no help我尝试使用谷歌搜索解决方案并遇到此链接此链接,但无法理解如何解决该问题,我什至通过一次添加一个 JAR 来重建项目,但没有帮助

[Update]: After adding lucene 5.5.2 jar getting below error: [更新]:添加 lucene 5.5.2 jar 后出现以下错误:

[TestNG] Running: C:\\Users\\vinbhask\\AppData\\Local\\Temp\\testng-eclipse--545647994\\testng-customsuite.xml Nov 06, 2016 9:18:20 AM org.elasticsearch.plugins.PluginsService INFO: [Locus] modules [], plugins [], sites [] FAILED: f java.lang.NoSuchMethodError: org.jboss.netty.channel.socket.nio.NioWorkerPool.(Ljava/util/concurrent/Executor;I)V at org.elasticsearch.transport.netty.NettyTransport.createClientBootstrap(NettyTransport.java:354) at org.elasticsearch.transport.netty.NettyTransport.doStart(NettyTransport.java:290) at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:68) at org.elasticsearch.transport.TransportService.doStart(TransportService.java:182) at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:68) at org.elasticsearch.client.transport.TransportClient$Builder.build(TransportClient.java:162) at elasticSearchTest.ES_Test_Class.f(ES_Test_Class.java:17) at sun.reflect.NativeMeth [TestNG] 运行:C:\\Users\\vinbhask\\AppData\\Local\\Temp\\testng-eclipse--545647994\\testng-customsuite.xml 2016 年 11 月 6 日上午 9:18:20 org.elasticsearch.plugins.PluginsService INFO:[ Locus] modules [], plugins [], sites [] FAILED: f java.lang.NoSuchMethodError: org.jboss.netty.channel.socket.nio.NioWorkerPool.(Ljava/util/concurrent/Executor;I)V at org .elasticsearch.transport.netty.NettyTransport.createClientBootstrap(NettyTransport.java:354) 在 org.elasticsearch.transport.netty.NettyTransport.doStart(NettyTransport.java:290) 在 org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.start(AbstractLifecycleComponent) .java:68) 在 org.elasticsearch.transport.TransportService.doStart(TransportService.java:182) 在 org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:68) 在 org.elasticsearch.client.transport。 TransportClient$Builder.build(TransportClient.java:162) at elasticSearchTest.ES_Test_Class.f(ES_Test_Class.java:17) at sun.reflect.NativeMeth odAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84) odAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method. java:497) 在 org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)

You are using Lucene 4.10.4, but Elasticsearch 2.4.1 is based on Lucene 5.5.2.您使用的是 Lucene 4.10.4,但 Elasticsearch 2.4.1 基于 Lucene 5.5.2。 Upgrade your Lucene version ( 5.5.2 is here ).升级您的 Lucene 版本(此处为 5.5.2 )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM