Reputation: 177
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...
Upvotes: 7
Views: 7905
Reputation: 11
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.
Upvotes: 1
Reputation: 33
I had the same issue, I downloaded the latest version of Joda-time jar and manually added it to project-structure-module-added joda jar took jar frim here https://github.com/JodaOrg/joda-time/releases and it worked
Upvotes: 0
Reputation: 1
I tried following:-
1) Changed the my java version to 1.8 2) Moved the aws dependency up in the pom before any other dependency declaration
It worked after that.
Upvotes: 0
Reputation: 1
If your project has Weblogic and AWS dependencies, make sure to have the the JODA time JAR first and the Weblogic JAR last so that it doesn't pickup the joda time from Weblogic JAR.
Upvotes: 0
Reputation: 3580
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.
Upvotes: 2