Reputation: 13915
How to fix NoClassDefFoundError: Could not initialize class org.slf4j.MDC
? I have in pom.xml
flyway plugin where slf4j
is excluded in favor of newer one.
[INFO] | \- org.slf4j:slf4j-simple:jar:1.5.6:compile
[INFO] +- org.springframework:spring-beans:jar:4.1.4.RELEASE:compile
[INFO] +- org.springframework:spring-core:jar:4.1.4.RELEASE:compile
[INFO] | \- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- org.springframework:spring-webmvc:jar:4.1.4.RELEASE:compile
[INFO] | +- org.springframework:spring-expression:jar:4.1.4.RELEASE:compile
[INFO] | \- org.springframework:spring-web:jar:4.1.4.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:4.1.4.RELEASE:compile
[INFO] +- org.springframework:spring-jdbc:jar:4.1.4.RELEASE:compile
[INFO] +- org.springframework:spring-orm:jar:4.1.4.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:4.1.4.RELEASE:compile
[INFO] | \- org.springframework:spring-aop:jar:4.1.4.RELEASE:compile
[INFO] | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.1.2:compile
[INFO] | +- ch.qos.logback:logback-core:jar:1.1.2:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.6:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.7.10:compile
pom.xml
<dependency>
<groupId>org.flywaydb.flyway-test-extensions</groupId>
<artifactId>flyway-spring4-test</artifactId>
<version>3.1</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${jcloverslf4j.version}</version>
</dependency>
Upvotes: 1
Views: 10892
Reputation: 2223
org.slf4j:slf4j-simple:jar:1.5.6:compile
org.slf4j:slf4j-api:jar:1.7.6:compile
org.slf4j:jcl-over-slf4j:jar:1.7.10:compile
These versions need to match. They don't match. At the very least, the minor versions (X in 1.X) need to match up. Also, get rid of slf4j-simple if you're using logback. Only one slf4j backend should be on the classpath.
Upvotes: 5