为弹性构造PreBuiltTransportClient时的NoSuchMethodError

时间:2017-09-12 14:35:52

标签: java elasticsearch apache-kafka elasticsearch-5 apache-kafka-connect

由于调试需要连接我的dockerized Elastic实例的Kafka连接器非常困难,我无法弄清楚为什么我会收到此异常......

当我尝试新传输客户端时:

Settings settings = Settings.builder()
        .put("cluster.name", clusterName).build();

client = new PreBuiltTransportClient(settings);
client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(url), port));

这是全班:https://github.com/skynyrd/kafka-connect-elastic-sink/blob/master/src/main/java/com/skynyrd/kafka/client/ElasticClientImpl.java

我收到此错误:

java.lang.NoSuchMethodError: org.elasticsearch.transport.client.PreBuiltTransportClient.addPlugins(Ljava/util/Collection;Ljava/util/Collection;)Ljava/util/Collection;
    at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:127)
    at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:113)
    at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:103)
    at com.skynyrd.kafka.client.ElasticClientImpl.<init>(ElasticClientImpl.java:33)
    at com.skynyrd.kafka.service.ElasticServiceImpl.<init>(ElasticServiceImpl.java:38)
    at com.skynyrd.kafka.ElasticSinkTask.start(ElasticSinkTask.java:30)
    at org.apache.kafka.connect.runtime.WorkerSinkTask.initializeAndStart(WorkerSinkTask.java:231)
    at org.apache.kafka.connect.runtime.WorkerSinkTask.execute(WorkerSinkTask.java:145)
    at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:139)
    at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:182)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
[2017-09-12 14:18:23,817] ERROR Task is being killed and will not recover until manually restarted (org.apache.kafka.connect.runtime.WorkerTask:142)
[2017-09-12 14:18:23,817] ERROR Task ElasticSinkConnector-0 threw an uncaught and unrecoverable exception during shutdown (org.apache.kafka.connect.runtime.WorkerTask:120)
java.lang.NullPointerException
    at com.skynyrd.kafka.ElasticSinkTask.stop(ElasticSinkTask.java:47)
    at org.apache.kafka.connect.runtime.WorkerSinkTask.close(WorkerSinkTask.java:131)
    at org.apache.kafka.connect.runtime.WorkerTask.doClose(WorkerTask.java:118)
    at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:145)
    at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:182)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)

以下是我在本地运行的存储库:https://github.com/skynyrd/kafka-connect-elastic-sink

我错过了什么吗?感谢

1 个答案:

答案 0 :(得分:0)

你可以使用maven shade插件构建一个超级jar。本文档描述了这种方法link