Following Getting Started with the AWS SDK for Java tutorial, to run the AwsConsoleApp
sample:
java -cp .:/Users/marius/Dev/aws-java-sdk-1.3.8/lib/aws-java-sdk-1.3.8.jar AwsConsoleApp
I get the following issues:
===========================================
Welcome to the AWS Java SDK!
===========================================
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at com.amazonaws.util.VersionInfoUtils.<clinit>(VersionInfoUtils.java:41)
at com.amazonaws.ClientConfiguration.<clinit>(ClientConfiguration.java:31)
at com.amazonaws.services.ec2.AmazonEC2Client.<init>(AmazonEC2Client.java:95)
at AwsConsoleApp.init(AwsConsoleApp.java:93)
at AwsConsoleApp.main(AwsConsoleApp.java:105)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 5 more
The same full SDK that was loaded in the classpath at compile time is given during runtime as well, so I can't figure out what's missing.
Among the SDK prerequisites, you have:
Requires Apache Commons (Codec, HTTP Client, and Logging) third-party packages, which are included in the third-party directory of the SDK.
so I just added them to my .bashrc
:
# Apache Commons Logging
export CLASSPATH=$CLASSPATH:/Users/marius/Dev/aws-java-sdk-1.3.8/third-party/commons-logging-1.1.1/*
# Apache Commons HTTP Client
export CLASSPATH=$CLASSPATH:/Users/marius/Dev/aws-java-sdk-1.3.8/third-party/httpcomponents-client-4.1.1/*
# Apache Commons Codec
export CLASSPATH=$CLASSPATH:/Users/marius/Dev/aws-java-sdk-1.3.8/third-party/commons-codec-1.3/*
On Windows add these paths to your system CLASSPATH
C:\aws-java-sdk-1.3.21.1\lib\aws-java-sdk-1.3.21.1.jar;
C:\aws-java-sdk-1.3.21.1\third-party\commons-logging-1.1.1\commons-logging-1.1.1.jar;
C:\aws-java-sdk-1.3.21.1\third-party\commons-codec-1.3\commons-codec-1.3.jar;
C:\aws-java-sdk-1.3.21.1\third-party\httpcomponents-client-4.1.1\httpclient-4.1.1.jar;
C:\aws-java-sdk-1.3.21.1\third-party\httpcomponents-client-4.1.1\httpcore-4.1.jar
then be sure to start with a new cmd prompt window after applying these.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With