AWS Kinesis客户端因java.lang.NoClassDefFoundError失败

时间:2016-06-09 19:20:06

标签: java amazon-web-services amazon-kinesis

我正在关注Kinesis Streams的http://docs.aws.amazon.com/streams/latest/dev/learning-kinesis-module-one.html教程。

我创建了两个包,一个包含Producer,另一个包含Consumer。我可以正确地生成数据,我可以从指标仪表板中看到数据进入流中。

当我运行我的消费者时,我得到以下堆栈跟踪:

1246 [main] DEBUG com.amazonaws.services.kinesis.samples.stocktrades.processor.StockTradesProcessor  - Caught throwable while processing data.
java.lang.NoClassDefFoundError: com/amazonaws/util/json/JSONObject
at com.amazonaws.services.kinesis.leases.impl.Lease.toString(Lease.java:229)
at java.lang.String.valueOf(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at com.amazonaws.services.kinesis.leases.impl.LeaseManager.createLeaseIfNotExists(LeaseManager.java:281)
at com.amazonaws.services.kinesis.clientlibrary.lib.worker.ShardSyncer.syncShardLeases(ShardSyncer.java:127)
at com.amazonaws.services.kinesis.clientlibrary.lib.worker.ShardSyncer.checkAndCreateLeasesForNewShards(ShardSyncer.java:88)
at com.amazonaws.services.kinesis.clientlibrary.lib.worker.ShardSyncTask.call(ShardSyncTask.java:68)
at com.amazonaws.services.kinesis.clientlibrary.lib.worker.MetricsCollectingTaskDecorator.call(MetricsCollectingTaskDecorator.java:49)
at com.amazonaws.services.kinesis.clientlibrary.lib.worker.Worker.initialize(Worker.java:395)
at com.amazonaws.services.kinesis.clientlibrary.lib.worker.Worker.run(Worker.java:330)
at com.amazonaws.services.kinesis.samples.stocktrades.processor.StockTradesProcessor.main(StockTradesProcessor.java:102)
Caused by: java.lang.ClassNotFoundException: com.amazonaws.util.json.JSONObject
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 11 more

2 个答案:

答案 0 :(得分:2)

我遇到了同样的问题。 只需将aws-sdk的版本更改为1.10.x.我用了1.10.7 可能你正在使用aws-sdk版本1.11.x

答案 1 :(得分:1)

Kinesis客户端库(KCL)与AWS Java SDK 1.11不兼容。您需要使用1.10.x。

这已在KCL 1.6.4中修复。因此,您可以更新KCL(> 1.6.4)以使用SDK 1.11.x. https://github.com/awslabs/amazon-kinesis-client/pull/75