关于elasticsearch java api错误

时间:2017-06-15 01:32:37

标签: java scala maven elasticsearch

我想使用spark-streaming来获取kafka数据并写入Es。我使用5.4 java API。我的环境是spark_2.1.1(独立),kafka是0.10.0.1,es是5.4.1。我可以正确地获取kafka数据。但是当我尝试向Es写入数据时,它会显示一些错误:

  

警告TaskSetManager:阶段0.0中的丢失任务1.0(TID 1,xxx):java.lang.NoSuchMethodError:io.netty.util.internal.ObjectUtil.checkPositive(ILjava / lang / String;)I       at io.netty.util.NettyRuntime $ AvailableProcessorsHolder.setAvailableProcessors(NettyRuntime.java:44)       at io.netty.util.NettyRuntime $ AvailableProcessorsHolder.availableProcessors(NettyRuntime.java:70)       at io.netty.util.NettyRuntime.availableProcessors(NettyRuntime.java:98)       at org.elasticsearch.transport.netty4.Netty4Utils.setAvailableProcessors(Netty4Utils.java:83)       在org.elasticsearch.transport.netty4.Netty4Transport。(Netty4Transport.java:138)       at org.elasticsearch.xpack.security.transport.netty4.SecurityNetty4Transport。(SecurityNetty4Transport.java:65)       在org.elasticsearch.xpack.security.Security.lambda $ getTransports $ 13(Security.java:779)       at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:176)       在org.elasticsearch.client.transport.TransportClient。(TransportClient.java:268)       在org.elasticsearch.transport.client.PreBuiltTransportClient。(PreBuiltTransportClient.java:127)       在org.elasticsearch.xpack.client.PreBuiltXPackTransportClient。(PreBuiltXPackTransportClient.java:55)       在org.elasticsearch.xpack.client.PreBuiltXPackTransportClient。(PreBuiltXPackTransportClient.java:50)       在org.elasticsearch.xpack.client.PreBuiltXPackTransportClient。(PreBuiltXPackTransportClient.java:46)

但我发现我有这样的方法,就像那样: Maven:io.netty:netty-all:4.1.11.Final and Maven:io.netty:netty-common:4.1.11.Final,他们都有正确的方法。

我的代码是这样的,出于安全原因xxx:

 val esc = new PreBuiltXPackTransportClient(settings)
      .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("xxx"), xxx))
      .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("xxx"), xxx))

1 个答案:

答案 0 :(得分:0)

你有两个拥有ObjectUtil类的jar。 JVM在运行时决定类,通常选择它获得的第一个类。我相信另一个会来自User jar。你能检查一次依赖树吗?