Reputation: 692
Currently I am working to add AWS Java SDK in my existing application to perform operations related to AWS cloud. While importing the aws java sdk for latest version i.e.1.11.113 I am getting run time exception. After researching about exception the reason is java sdk using deprecated version or incompatible version for jackson jar.
The sdk is using jackson jar of version 4.1 while required version must at least 5. Even I am giving latest jackson jar but still it is taking reference of jar present in SDK. Below code snapshot will help to identify this easily
Caused by: java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.ObjectMapper.enable([Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/databind/ObjectMapper;
at com.amazonaws.partitions.PartitionsLoader.<clinit>(PartitionsLoader.java:54) [aws-java-sdk-core-1.11.113.jar:]
at com.amazonaws.regions.RegionMetadataFactory.create(RegionMetadataFactory.java:30) [aws-java-sdk-core-1.11.113.jar:]
at com.amazonaws.regions.RegionUtils.initialize(RegionUtils.java:64) [aws-java-sdk-core-1.11.113.jar:]
at com.amazonaws.regions.RegionUtils.getRegionMetadata(RegionUtils.java:52) [aws-java-sdk-core-1.11.113.jar:]
at com.amazonaws.regions.RegionUtils.getRegion(RegionUtils.java:105) [aws-java-sdk-core-1.11.113.jar:]
at com.amazonaws.regions.Region.getRegion(Region.java:43) [aws-java-sdk-core-1.11.113.jar:]
How can I avoid code to use this particular jar and make it use latest jar . I am using gradle as build tool.
Upvotes: 3
Views: 3680
Reputation: 1865
Are you using maven? I had a similar issue to use joda-time before and then solved using by <exclusion>
tag. <exclusion>
tag could be used to exclude the old jackson in your aws-java-sdk. Following is the way to solve the issue:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.11.113</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.8</version>
</dependency>
Upvotes: 3