学习Amazon Kinesis Streams开发 - java.lang.NoClassDefFoundError:com / amazonaws / util / json / JSONObject

时间:2016-06-13 22:15:06

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

我试图在此处找到的Kinesis Streams上运行以下AWS教程,http://docs.aws.amazon.com/streams/latest/dev/learning-kinesis-module-one-consumer.html,项目的Producer部分(StockTradesWriter.java)运行正常,但我得到以下内容我尝试运行项目的Consumer部分(StockTradesProcessor.java)时出错。

Jun 13, 2016 6:03:36 PM com.amazonaws.services.kinesis.samples.stocktrades.processor.StockTradesProcessor main
SEVERE: 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(String.java:2994)
    at java.lang.StringBuilder.append(StringBuilder.java:131)
    at com.amazonaws.services.kinesis.clientlibrary.lib.worker.ShardSyncer.determineNewLeasesToCreate(ShardSyncer.java:345)
    at com.amazonaws.services.kinesis.clientlibrary.lib.worker.ShardSyncer.syncShardLeases(ShardSyncer.java:121)
    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:117)
Caused by: java.lang.ClassNotFoundException: com.amazonaws.util.json.JSONObject
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 11 more

因此,由于某种原因无法找到此课程http://javadox.com/com.amazonaws/aws-java-sdk-core/1.9.26/com/amazonaws/util/json/JSONObject.html

我在Eclipse中使用Java 8运行它,并且我已经包含了Kinesis Client Library(KCL)版本1.6.3和AWS SDK for Java版本1.11.7。这是我的Eclipse的屏幕截图项目:

enter image description here

注意:要下载并运行此程序,您可以在此必备页面上找到所需的一切:http://docs.aws.amazon.com/streams/latest/dev/learning-kinesis-module-one-begin.html

2 个答案:

答案 0 :(得分:0)

显然,最新的AWS SDK(1.11.x)不适用于本教程。我把版本降到了1.10.76,一切都开始了......感谢亚马逊。

enter image description here

答案 1 :(得分:0)

升级到KCL v1.7.2似乎已经为我修复了它。我使用的是AWS SDK 1.11.58。

不确定问题何时引入或修复