Nadav
Nadav

Reputation: 1110

mockserver causes dependency collision in springboot test

Summary

When running a springboot test, I get dependency collision, which I can't get rid of.

Details

My build.gradle.kts includes the following line:

testImplementation("org.mock-server:mockserver-netty-no-dependencies:5.14.0") {
        exclude(group = "org.slf4j", module = "slf4j-nop")
    }

It also contains springboot 3 dependencies and some others.

When running tests, annotated with @SpringBootTest, the tests fail, with collision between Logback and NOPLoggerFactory. Full error is:

java.lang.IllegalStateException: Failed to load ApplicationContext for [WebMergedContextConfiguration@4cc65c2 .... (removed irrelevant data)

Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.helpers.NOPLoggerFactory loaded from file:/root/.gradle/caches/modules-2/files-2.1/org.mock-server/mockserver-netty-no-dependencies/5.14.0/cbb65da96b8a4f0abfc8b6ff2f800f51572990a4/mockserver-netty-no-dependencies-5.14.0.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.slf4j.helpers.NOPLoggerFactory

As you can see, I've tried to exclude slf4j-nop, but it doesn't seem to help.

When I run:

./gradlew dependencies --configuration testRuntimeClasspath | grep nop 

Nothing gets printed, as if there is no dependency in slf4j-nop.

When I remove the dependency in mockserver-netty-no-dependencies, the error doesn't happen.

Any insight?

Upvotes: 1

Views: 106

Answers (0)

Related Questions