Why do I keep getting NoSuchMethodError on LocationAwareLogger?
I'm trying to embed Jetty server into my automated tests so I've added the
following dependency in my project:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>7.6.13.v20130916</version>
<scope>test</scope>
</dependency>
I'm using Jetty 7 because the Web app uses Java 6, Servlet 2.5.
However when I try to start embedded Jetty server, I get:
java.lang.NoSuchMethodError:
org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
at
org.eclipse.jetty.util.log.JettyAwareLogger.log(JettyAwareLogger.java:607)
at
org.eclipse.jetty.util.log.JettyAwareLogger.warn(JettyAwareLogger.java:431)
at org.eclipse.jetty.util.log.Slf4jLog.warn(Slf4jLog.java:69)
at
org.eclipse.jetty.util.component.AbstractLifeCycle.setFailed(AbstractLifeCycle.java:204)
at
org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:74)
I've been trying to figure out what's wrong but none of the steps I've
taken so far addresses the issue. Here's a list of what I've done so far:
Trace transitive dependencies to search for incompatible versions of
slf4j-api
Try out different versions of slf4j-api (1.5.11, 1.6.1, 1.6.4, 1.7.5)
Looked into the some sources of Jetty 7 particularly the pom.xml and found
that there's a dependency to slf4j 1.6.1
Looked into this similar question and got null when trying to print
org.slf4j.spi.LocationAwareLogger, and org.slf4j.Marker
I hope someone can offer a fresh insight into this issue. Thanks.
I think you've faced a compatibility problem between sl4j jars. Try examinating mvn dependency:tree output of your final artifact. Maybe you have two different versions of some sl4j jar and you cannot predict which loads first. Try to equalize all sl4j versions.
ReplyDelete