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

common logging can't work well with slf4j-api-1.7.10.jar #370

Closed
jackyq2015 opened this issue Mar 2, 2015 · 2 comments
Closed

common logging can't work well with slf4j-api-1.7.10.jar #370

jackyq2015 opened this issue Mar 2, 2015 · 2 comments

Comments

@jackyq2015
Copy link

The version of aws-sdk-java is aws-java-sdk-1.9.22.jar. When I try to make a s3 connection, I got following error:

java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
at org.apache.commons.logging.impl.SLF4JLocationAwareLog.debug(SLF4JLocationAwareLog.java:120)
at com.amazonaws.internal.config.InternalConfig.load(InternalConfig.java:258)
at com.amazonaws.internal.config.InternalConfig$Factory.(InternalConfig.java:284)
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.(ClientConfiguration.java:42)
at com.amazonaws.services.s3.AmazonS3Client.(AmazonS3Client.java:361)
at com.google.refine.importing.camel.CamelRouteBuilder.configure(CamelRouteBuilder.java:52)

The jar I am using is slf4j-api-1.7.10.jar, commons-logging-1.1.3.jar(which extract from aws-sdk zip), log4j-1.2.17.jar. In the zip file from the github,, there's no dependency of the slf4j.

Not sure why common logging delegate to slf4j. My understand is to use log4j as the implementation. I checked the failed signature, it was used until slf4j-api-1.5.58.jar. But my main program has to be slf4j-api-1.7.10.jar(otherwise will complain other similar signature issue)

Looking for some workaround for this problem. or change the code base to work with updated slf4j-api-1.7.10.

@david-at-aws
Copy link
Contributor

Despite its Java package, org.apache.commons.logging.impl.SLF4JLocationAwareLog comes from Slf4j's jcl-over-slf4j module. You've presumably got a version of this on your classpath before the actual commons-logging implementation, which is why the SDK appears to be trying to use slf4j. The exception you're getting sounds like the version of jcl-over-slf4j you're picking up isn't compatible the version of slf4j-api you're using.

As I understand it, you've got two options:

  1. Remove jcl-over-slf4j from your classpath. The SDK will then be sure to load the actual commons-logging implementation, which will call directly to log4j without touching slf4j. The rest of your application can use slf4j's API, which will also ultimately route down to log4j.
  2. Pull in a version of jcl-over-slf4j that's compatible with your version of slf4j-api. You can then safely drop commons-logging. The SDK (and any other libraries that use commons-logging) will get the jcl-over-slf4j implementation and end up calling through slf4j-api to log4j.

@jackyq2015
Copy link
Author

@david-at-aws , You are right! I remvoed the jcl-over-slf4j. now it works well.

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

2 participants