NoClassDefFoundError while running a program using AWS SDK for java

半腔热情 提交于 2019-12-13 12:26:28

问题


Im trying to run the DynamoDB sample that comes with the AWS SDK for java. Im doing it using eclipse, and added the aws-java-sdk-1.3.2.jar file to the build path of the project. Compilation of course goes fine, but im getting a runtime exception named NoClassDefFoundError. I know it means that the class was there at compilation but couldn't be found at runtime. I tried adding the jar file to env variables - didn't help. I also checked and there is no problem using other external jar files on other projects. Same problem on both windows and linux.

help anyone?

Thanks, ben.

Stack Trace:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    at com.amazonaws.services.dynamodb.AmazonDynamoDBClient.<clinit>(AmazonDynamoDBClient.java:62)
    at AmazonDynamoDBSample.init(AmazonDynamoDBSample.java:62)
    at AmazonDynamoDBSample.main(AmazonDynamoDBSample.java:67)

回答1:


Inside the aws-java-sdk-1.3.2 folder you will find another folder named "third-party". All the third-party files used by Amazon SDK are inside that folder, including Apache Common Logging. You have to add the required files to your classpath along with AWS SDK jar files.




回答2:


It looks like your AWS JAR needs a few extra JARs to implement used, but non-AWS items (like in your case logging).

If you downloaded a distributable that contains a "lib" directory, odds are you only configured Eclipse to use the AWS JAR instead of all the required JARs, including AWS and probably all the JARs in the "lib" directory.



来源:https://stackoverflow.com/questions/11018904/noclassdeffounderror-while-running-a-program-using-aws-sdk-for-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!