Java – why do you always get nosuchmethoderror on locationawarelogger when running jetty?
I'm trying to embed jetty server into my automated test, so I added the following dependencies to 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 application uses Java 6, servlet 2.5
However, when I tried to start the embedded jetty server, I got:
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 so far, none of the steps I've taken have solved the problem Here is a list of what I have done so far:
>Trace delivery dependencies to search for incompatible versions of slf4j API > try different versions of slf4j API (1.5.11,1.6.1,1.6.4,1.7.5) > check out some sources of jetty 7, especially POM XML and found that it depends on slf4j 1.6 1 > view this similar question and try to print org slf4j. spi. Locationawarelogger and org slf4j. Get null when marker
I hope someone can provide new insights into this problem thank you.
Solution
I bet you have a compatibility problem between sl4j cans Try to check MVN dependencies: the tree output of the final artifact Maybe you have two different versions of sl4j jars. You can't predict which loads first Try to balance all sl4j versions
OP: see documentation on how I resolved this