Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoClassDefFoundError while running a program using AWS SDK for java

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)
like image 375
Ben Danon Avatar asked Jun 13 '12 16:06

Ben Danon


2 Answers

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.

like image 187
Pedro Aurélio Avatar answered Sep 28 '22 03:09

Pedro Aurélio


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.

like image 43
Edwin Buck Avatar answered Sep 28 '22 02:09

Edwin Buck