Mr. Tea Mr. Tea - 11 days ago 5
Java Question

Learning Amazon Kinesis Streams Development - java.lang.NoClassDefFoundError: com/amazonaws/util/json/JSONObject

I'm trying to run the following AWS tutorial on Kinesis Streams found here, http://docs.aws.amazon.com/streams/latest/dev/learning-kinesis-module-one-consumer.html, the Producer portion of the project (StockTradesWriter.java) works just fine but I'm getting the following error when I try to run the Consumer portion of the project (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


So this class, http://javadox.com/com.amazonaws/aws-java-sdk-core/1.9.26/com/amazonaws/util/json/JSONObject.html, cannot be found for some reason.

I'm running this in Eclipse, using Java 8, and I have included the Kinesis Client Library (KCL) version 1.6.3 and the AWS SDK for Java version 1.11.7.Here is a screenshot of my Eclipse project:

enter image description here

Note: To download and run this program you can find everything you need on this prerequisite page: http://docs.aws.amazon.com/streams/latest/dev/learning-kinesis-module-one-begin.html

Answer

Evidently the latest AWS SDK (1.11.x) does not work for this tutorial. I dropped the version down to 1.10.76 and everything started working... Thanks Amazon.

enter image description here