I got a common issue with the aws sdk and joda-time. And even if there are many of these issues on the internet, I am still not able to fix that...
Exception in thread "main" java.lang.NoSuchMethodError: org.joda.time.format.DateTimeFormatter.withZoneUTC()Lorg/joda/time/format/DateTimeFormatter;
at com.amazonaws.auth.internal.AWS4SignerUtils.<clinit>(AWS4SignerUtils.java:26)
at com.amazonaws.auth.internal.AWS4SignerRequestParams.<init>(AWS4SignerRequestParams.java:85)
at com.amazonaws.auth.AWS4Signer.sign(AWS4Signer.java:168)
at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:814)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:607)
at com.amazonaws.http.AmazonHttpClient.doExecute(AmazonHttpClient.java:376)
at com.amazonaws.http.AmazonHttpClient.executeWithTimer(AmazonHttpClient.java:338)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:287)
at com.amazonaws.services.ec2.AmazonEC2Client.invoke(AmazonEC2Client.java:11132)
at com.amazonaws.services.ec2.AmazonEC2Client.runInstances(AmazonEC2Client.java:10657)
at cloudSteuerung.AmazonWebServices.create(AmazonWebServices.java:33)
at de.bla.ccu.Test.main(Test.java:16)
Checking the dependency tree of maven I noticed several joda dependencies. AWS seems to need version 2.8.1 so I added it explicitly in the pom-file but the error still occurs. I tried several versions of joda but no version seems to work properly. Can anyone help me? I am just trying to run the AWS sdk EC2 example...
I experienced this issue when declaring our AWS dependency using the aws-java-sdk artifactId. e.g.
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>x.y.z</version>
</dependency>
We changed to importing the aws-java-sdk-bom dependency, as recommended by Amazon, e.g.
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-bom</artifactId>
<version>x.y.z</version>
<type>pom</type>
<scope>import</scope>
</dependency>
and then declaring our component dependencies individually, e.g.
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
</dependency>
This allowed Maven to determine the correct joda-time dependency for the aws-sdk and resolved the issue.
Obviously this means that the class-path is referring to a JAR which is of a lower version than the one that you are using (2.8.1)
I am using AWS SDK on JBOSS 6.2 EAP and had the same issue. I found that JBOSS has its own JODA under the "modules" folder which gets loaded first ignoring the JODA version I had in my lib folder. I deleted the entry of ORG.JODA in my MANIFEST.MF which means that the classloader will now look for the JODA jar from the lib. This fixed my issue.
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