gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 05:56:37 26 4
gpt4 key购买 nike

当我使用 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)

我不明白这是怎么发生的,有人能遇到这个问题吗?谢谢!!!

最佳答案

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

如果是这种情况,您需要排除 JBoss 包,即 org.jboss.nettypackage,这样就可以了。

关于ElasticSearch 连接本地环境时无法获取 TransPortClient,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35539535/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com