0

I have a class and I use

String signingAlgorithm = SigningAlgorithm.HmacSHA256.toString();

there. class works fine when I running unit test or main method. But it gives this exception

Exception in thread "main" java.lang.NoClassDefFoundError: com/amazonaws/auth/SigningAlgorithm

when I call jar

<dependency>
     <groupId>com.amazonaws</groupId>
     <artifactId>aws-java-sdk</artifactId>
     <version>1.7.2</version>
</dependency>

I use maven-jar-plugin

<manifest>
     <addClasspath>true</addClasspath>
     <classpathPrefix>lib/</classpathPrefix>
     <mainClass>com.example.my.MainClass</mainClass>
</manifest>

any idea?

Darshana
  • 2,462
  • 6
  • 28
  • 54
  • You need to have the AWS jar file (and maybe other dependencies) somewhere, maybe in `lib/` under the current directory. I recommend building a jar-with-dependencies that bundles them all to simplify deployment. – Thilo Jun 25 '14 at 09:31
  • ya. I have the `aws-java-sdk` in maven dependencies. version `1.7.2` – Darshana Jun 25 '14 at 09:35
  • that won't automatically put them into the jar file. But it could be something else. Do you have the full stacktrace? – Thilo Jun 25 '14 at 09:36
  • 1
    yeah, looks like a dependency jar is missing. If your manifest says `lib/aws.jar` you need to have that jar file in addition to your own. It won't load it magically from the Maven repo. – Thilo Jun 25 '14 at 09:53
  • @Thilo `Exception in thread "main" java.lang.NoClassDefFoundError: com/amazonaws/auth/SigningAlgorithm at com.example.my.SignatureUtil.getEncoded(SignatureUtil.java:85) at com.example.my.SignatureUtil.generateSignature(SignatureUtil.java:50) at com.example.my.MainClass.main(MainClass.java:13) Caused by: java.lang.ClassNotFoundException: com.amazonaws.auth.SigningAlgorithm at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190)` – Darshana Jun 25 '14 at 09:56
  • you mean, adding `aws-java-sdk` dependency won't just do the job. do I need to keep seperate `aws' jar with may project jar? – Darshana Jun 25 '14 at 10:01
  • @Thilo Thanks for your help. I follow this answer to package deps. http://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven – Darshana Jun 25 '14 at 10:36

0 Answers0