连接本地环境时,ElasticSearch无法获取TransPortClient

时间:2016-02-21 17:40:17

标签: elasticsearch

当我使用TransPortClient方法创建ElasticSearch客户端时。 代码是这样的:

public static void main(String[] args) {

    // ES config
    Settings settings = settingsBuilder()
            .put("cluster.name", "dev-application")
            .put("client.transport.sniff", true)
            .build();
    // ES client
    try {
        TransportClient client = TransportClient.builder().settings(settings).build()
                .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("127.0.0.1"), 9300));
    } catch (Exception e) {
        System.out.println("print");
        e.printStackTrace();
    }
    System.out.println("print");
}

但我收到错误信息显示如下:

01:32:09.288 [main] DEBUG org.elasticsearch.client.transport - [Magilla] node_sampler_interval[5s]
Disconnected from the target VM, address: '127.0.0.1:54569', transport: 'socket'
Exception in thread "main" java.lang.VerifyError: (
  class: org/jboss/netty/channel/socket/nio/NioWorkerPool, 
  method: newWorker signature(Ljava/util/concurrent/Executor;)Lorg/jboss/netty/channel/socket/nio/AbstractNioWorker;) 
  Wrong return type in function
    at org.elasticsearch.transport.netty.NettyTransport.createClientBootstrap(NettyTransport.java:349)
    at org.elasticsearch.transport.netty.NettyTransport.doStart(NettyTransport.java:277)
    at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:68)
    at org.elasticsearch.transport.TransportService.doStart(TransportService.java:170)
    at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:68)
    at org.elasticsearch.client.transport.TransportClient$Builder.build(TransportClient.java:159)
    at com.dmall.dms.fastdelivery.service.parser.SimpleParserServiceTest.main(SimpleParserServiceTest.java:26)

我无法理解这是怎么发生的,有人能遇见这个问题吗?感谢!!!

1 个答案:

答案 0 :(得分:5)

您似乎与来自两个不同JAR(JBoss和Jlasticsearch)的Netty类存在依赖冲突。

如果是这种情况,你需要排除JBoss,即org.jboss.nettypackage,你应该很好。