Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception while initializing AmazonS3Client #555

Closed
leoromanovsky opened this issue Nov 16, 2015 · 30 comments
Closed

Exception while initializing AmazonS3Client #555

leoromanovsky opened this issue Nov 16, 2015 · 30 comments

Comments

@leoromanovsky
Copy link

When calling:

new AmazonS3Client(new ProfileCredentialsProvider().getCredentials())

This exception occurs:

Exception in thread "main" java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.ObjectMapper.enable([Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/databind/ObjectMapper;
        at com.amazonaws.internal.config.InternalConfig.<clinit>(InternalConfig.java:43)
        at com.amazonaws.internal.config.InternalConfig$Factory.<clinit>(InternalConfig.java:304)
        at com.amazonaws.util.VersionInfoUtils.userAgent(VersionInfoUtils.java:139)
        at com.amazonaws.util.VersionInfoUtils.initializeUserAgent(VersionInfoUtils.java:134)
        at com.amazonaws.util.VersionInfoUtils.getUserAgent(VersionInfoUtils.java:95)
        at com.amazonaws.ClientConfiguration.<clinit>(ClientConfiguration.java:53)
        at com.amazonaws.services.s3.AmazonS3Client.<init>(AmazonS3Client.java:384)

"com.amazonaws" % "aws-java-sdk" % "1.10.34"

@leoromanovsky
Copy link
Author

@shorea
Copy link
Contributor

shorea commented Nov 16, 2015

Our minimum version of Jackson required is 2.5.3. We've only recently added code that uses new APIs in Jackson.

@samyuktr
Copy link

Hi,

I am using jackson version 2.8.0 but the problem still persists. I am trying to upload some files onto amazon S3. I'm using aws-java-sdk-1.11.15
I am using ant to build my project. I get the following on running my code -

Exception in thread "main" java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.ObjectMapper.enable([Lcom/fasterx
ml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/databind/ObjectMapper;
at com.amazonaws.partitions.PartitionsLoader.(PartitionsLoader.java:54)
at com.amazonaws.regions.RegionMetadataFactory.create(RegionMetadataFactory.java:30)
at com.amazonaws.regions.RegionUtils.initialize(RegionUtils.java:66)
at com.amazonaws.regions.RegionUtils.getRegionMetadata(RegionUtils.java:54)
at com.amazonaws.regions.RegionUtils.getRegion(RegionUtils.java:107)
at com.amazonaws.services.s3.AmazonS3Client.createSigner(AmazonS3Client.java:3256)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3952)
at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1538)
at code4goal.antony.resumeparser.ResumeParserProgram.main(ResumeParserProgram.java:613)

For this piece of code - s3client.putObject(new PutObjectRequest(bucketName, keyName, file));

@KumareshBabuNS
Copy link

Hi samyuktr,

I think you are using older version of jackson in the project.
Cause of error:
Compiler checks the jackson older version then the latest version of jackson.
Try to remove the other version of jackson. I had same problem in my spring project.
I removed older versions of same artifact and I resolved the error.

@shorea
Copy link
Contributor

shorea commented Jul 14, 2016

Our new minimum is 2.6 but if you are using 2.8 it should be fine. Are you positive that 2.8 is being used at runtime or is it possible that your application is pulling in an older version.

Can you try printing this to see where the Jackson classes are being loaded from?
ObjectMapper.class.getProtectionDomain().getCodeSource()

@samyuktr
Copy link

@KumareshBabuNS I have removed all older versions of jackson. I currently have only 2.8

@shorea Could you please expand on how to check where the jackson classes are being loaded from?
My code doesn't seem to recognize ObjectMapper when I try to print ObjectMapper.class.getProtectionDomain().getCodeSource().

@KumareshBabuNS
Copy link

@samyuktr If you using eclipse IDE, you need to add jackson jar file into Deployment Assembly.

@samyuktr
Copy link

@KumareshBabuNS I'm using CLI. No IDE.

@shorea
Copy link
Contributor

shorea commented Jul 14, 2016

Here's a complete example.
System.out.println(com.fasterxml.jackson.databind.ObjectMapper.class.getProtectionDomain().getCodeSource().getLocation())

@samyuktr
Copy link

@shorea Fixed it!
It was reading a lower jackson version from the aws-java-core folder.
Thank you so much. @shorea @KumareshBabuNS

@shorea
Copy link
Contributor

shorea commented Jul 14, 2016

Glad we could help. Thanks for commenting on the same issue instead of creating a new one. Helps keep the conversation in one place and helps other people fix their issues faster.

@jorba-tradedoubler
Copy link

Hi there,

I'm still experiencing this issue when deploying in Beanstalk. I followed the steps mentioned here and it seems that the problem is in glassfish (the system.out.print returned file:/usr/local/glassfish4/glassfish/modules/jackson-databind.jar in beanstalk), is there something I can do to fix this?

@kiiadi
Copy link
Contributor

kiiadi commented Oct 27, 2016

@jorba-tradedoubler I don't know a whole lot about glassfish - never used it before - does it bundle in versions of common jars? How does it do dependency resolution?

What version of the SDK are you using? Minimum required Jackson version is 2.6.6 as of 1.11.1 of the SDK.

@madaquheng
Copy link

madaquheng commented Nov 1, 2016

I met this issue too with aws-java-sdk-dynamodb 1.11.49. Adding jackson-databind 2.8.4 can fix this error.

@davidmoten
Copy link
Contributor

glassfish 4.1.1 does bunde in some jackson jars:

./glassfish/modules/jackson-jaxrs-base.jar
./glassfish/modules/jackson-annotations.jar
./glassfish/modules/jersey-media-json-jackson.jar
./glassfish/modules/jackson-databind.jar
./glassfish/modules/jackson-jaxrs-json-provider.jar
./glassfish/modules/jackson-core.jar

jackson-core.jar is at version 2.3.2 so this is why our glassfish deployed app is getting problems. Not sure if I can safely override any of this, I'll see.

@davidmoten
Copy link
Contributor

davidmoten commented Nov 16, 2016

overriding is easy. Add WEB-INF/glassfish-web.xml to your webapp with later jackson dependencies with this content:

<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD 
GlassFish Application Server 3.1 Servlet 3.0//EN" 
"http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
   <class-loader delegate="false"/>
</glassfish-web-app>

Despite the references to 3.1 in DOCTYPE it works fine with 4.1.1.

@the-esculator
Copy link

@davidmoten I have a big project that is heavily dependant on the bundled jars in glassfish. Would you know a way that I can isolate just the bundled jackson jars, or update the jars in the bundle itself?

@davidmoten
Copy link
Contributor

davidmoten commented Nov 25, 2016 via email

@davidmoten
Copy link
Contributor

davidmoten commented Nov 25, 2016 via email

@hearlapati-phunware
Copy link

hearlapati-phunware commented Dec 14, 2016

If upgrading jackson jar's in your project is not an option and you still want to use AmazonS3 functions, I would recommend to use aws-sdk-1.2.7.jar. That aws jar is compatible with my Jackson 1.9.2 jars

@anuragmishra1991
Copy link

@samyuktr
I am facing same issue. Can you please provide the solution which you have used to resolve this.

@jagumant
Copy link

i m using latest jackson(2.8.9) but still i am getting the same error.
+++++++++++++++++++++++++++++++
spark-1.6.3-bin-hadoop2.6/python/lib/pyspark.zip/pyspark/streaming/kinesis.py", line 86, in createStream
py4j.protocol.Py4JJavaError: An error occurred while calling o26.createStream.
: java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.ObjectMapper.enable([Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/databind/ObjectMapper;
+++++++++++++++++++++++++++++++

let me know anyone got any fix for the same

@anuragmishra1991
Copy link

anuragmishra1991 commented Jul 11, 2017

@jagumant

Which is your deployment server? Wildfly, Tomcat etc

In case of wildfly the location where you may need to manually change the jar file for required version is
"/opt/wildfly-8.2.0.Final/modules/system/layers/base/com/fasterxml". Similarly for tomcat and others.

Please refer "#1120" for more detail.
I hope this will help you.

@rmundkowsky
Copy link

rmundkowsky commented Nov 11, 2017

So I am getting this error and what I do not understand is that the jar (aws-java-sdk) according to Maven doesn't have any dependencies. Why is the jackson dependency not correctly associated to this jar in the Maven repos? Hmm, actually looks correct in the repo, guess it is my Eclipse tool that is not showing the dependencies, odd

@shorea
Copy link
Contributor

shorea commented Nov 11, 2017

@rmundkowsky dependencies are a fickle business. Can you run mvn:dependencyTree to see how things are being resolved?

@rmundkowsky
Copy link

Tree output from a sample project is below. My guess is that maven does not handle "modules" properly. Maybe there is a maven option I need to use.

aws dependency:

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

INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ test2 ---
[INFO] foo.bar:test2:jar:0.0.1-SNAPSHOT
[INFO] +- junit:junit:jar:3.8.1:test
[INFO] - com.amazonaws:aws-java-sdk:jar:1.11.210:compile
[INFO] ------------------------------------------------------------------------

@rmundkowsky
Copy link

I likely do not understand what "modules" means in maven. It seems it might just be to note that you need to build other sub-modules for a project, and not that they are dependencies. I would think it would be a good idea to have them as dependencies as well, otherwise pulling aws-java-sdk from a maven repo gets you the aws jars without any of the dependencies.

@tapanbanker
Copy link

WARNING: The legacy profile format requires the 'profile ' prefix before the profile name. The latest code does not require such prefix, and will consider it as part of the profile name. Please remove the prefix if you are seeing this warning.
Exception in thread "main" 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.(PartitionsLoader.java:54)
at com.amazonaws.regions.RegionMetadataFactory.create(RegionMetadataFactory.java:30)
at com.amazonaws.regions.RegionUtils.initialize(RegionUtils.java:64)
at com.amazonaws.regions.RegionUtils.getRegionMetadata(RegionUtils.java:52)
at com.amazonaws.regions.RegionUtils.getRegion(RegionUtils.java:105)
at com.amazonaws.client.builder.AwsClientBuilder.setRegion(AwsClientBuilder.java:369)
at com.amazonaws.client.builder.AwsClientBuilder.configureMutableProperties(AwsClientBuilder.java:337)
at com.amazonaws.client.builder.AwsSyncClientBuilder.build(AwsSyncClientBuilder.java:46)
at io.aws.s3.utilility.AWSS3Utility.listS3Buckets(AWSS3Utility.java:47)
at ApplicationExcel.main(ApplicationExcel.java:33)

Process finished with exit code 1

The POM.XML File
com.github.fge
json-schema-validator
2.2.6


com.github.fge
jackson-coreutils
1.8


com.github.fge
json-schema-core
1.2.5


com.fasterxml.jackson.core
jackson-databind
2.4.1

@edenpan
Copy link

edenpan commented Feb 28, 2018

Hi, i also have the same problem. That i am use the glassfish server and the aws sdk is 1.11.271. And i print the jar location during the runtime:
file:/home/ubuntu/glassfish4/glassfish/domains/domain1/applications/BookStore/WEB-INF/lib/jackson-databind-2.6.7.1.jar

the error log as below:
StandardWrapperValve[AddToOrderServlet]: Servlet.service() for servlet AddToOrderServlet threw exception
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.(PartitionsLoader.java:54)
at com.amazonaws.regions.RegionMetadataFactory.create(RegionMetadataFactory.java:30)
at com.amazonaws.regions.RegionUtils.initialize(RegionUtils.java:64)
at com.amazonaws.regions.RegionUtils.getRegionMetadata(RegionUtils.java:52)
at com.amazonaws.regions.RegionUtils.getRegion(RegionUtils.java:105)
at com.amazonaws.regions.Region.getRegion(Region.java:43)
at AddToOrderServlet.doPost(AddToOrderServlet.java:152)

@ndvalencia
Copy link

Hi, I was having this problem using GlassFish Server 4.1 and aws-java-sdk-s3 - 1.11.371, In my case the jackson libraries were being loaded from Glassfish modules folder (C:\Program Files\glassfish-4.1\glassfish\modules) even if I was including them explicity in my POM:

<dependency> 
   <groupId>com.amazonaws</groupId> 
   <artifactId>aws-java-sdk-s3</artifactId> 
   <version>1.11.371</version> 
</dependency> 
<dependency> 
   <groupId>com.fasterxml.jackson.core</groupId> 
   <artifactId>jackson-core</artifactId> 
   <version>2.6.7</version> 
</dependency> 
<dependency> 
   <groupId>com.fasterxml.jackson.core</groupId> 
   <artifactId>jackson-databind</artifactId> 
   <version>2.6.7</version> 
</dependency> 
<dependency> 
   <groupId>com.fasterxml.jackson.core</groupId> 
   <artifactId>jackson-annotations</artifactId> 
   <version>2.6.7</version> 
</dependency>

So, in my case the solution that @davidmoten posted on #555 (comment) helped me (Thanks a lot @davidmoten )

Regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests