2016-06-13 65 views
0

我想在這裏找到的Kinesis Streams上運行以下AWS教程,http://docs.aws.amazon.com/streams/latest/dev/learning-kinesis-module-one-consumer.html,該項目的Producer部分(StockTradesWriter .java)工作得很好,但當我嘗試運行項目的Consumer部分(StockTradesProcessor.java)時,出現以下錯誤。學習亞馬遜Kinesis Streams開發 - java.lang.NoClassDefFoundError:com/amazonaws/util/json/JSONObject

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客戶端庫(KCL)版本1.6.3和適用於Java版本1.11.7的AWS開發工具包。這裏是我的Eclipse項目的屏幕截圖:

enter image description here

注:下載並運行這個程序,你可以找到你需要這個前提頁面上的所有內容:http://docs.aws.amazon.com/streams/latest/dev/learning-kinesis-module-one-begin.html

回答

0

顯然,最新的AWS SDK(1.11.x)不適合工作本教程。我把版本下降到1.10.76,一切開始運作......感謝亞馬遜。

enter image description here

+0

這是不是一個真正的答案看,如果你需要使用1.11.x的具體原因,它並沒有解決問題 –

+0

沒有?它確實解決了我的問題... –

+0

有人請爲1.11.x提供解決方案 – masSdev

0

升級到KCL V1.7.2似乎已經解決了對我來說。我正在使用AWS SDK 1.11.58。

不知道當問題被引入或固定