What is wrong for this error

Spring framework throws

Exception in thread "main" 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.info(SLF4JLocationAwareLog.java:159) at org.springframework.context.support.AbstractApplicationContext.prepareRefresh(AbstractApplicationContext.java:454) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:392) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93) 

what reason?

+7
source share
3 answers

The reason for the incorrect version of the added library (version conflict).

Check the version of slf4j javadoc and try to find out slf4j this method exists with which version?

+8
source

If you are using OSX, you may find that this is because the following files are included as java extensions:

/Library/Java/Extensions/slf4j-api-1.5.8.jar

/Library/Java/Extensions/slf4j-log4j12-1.5.8.jar

They are loaded by the extension class loader before loading the application class, so they will be allowed first.

I have no idea why they were or when they were added, but I saw it only on OSX and last year, which may mean that they were introduced in java 6.

You can delete / move files to work around the problem, but there may be some applications that depend on them.

+2
source

You may have a class twice in your class path.

Check the classpath for entries.

+1
source

All Articles