mock-server / mockserver

MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby. MockServer also includes a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding).
http://mock-server.com
Apache License 2.0
4.61k stars 1.08k forks source link

SLF4J multiple bindings when following documentation with 5.13.2 version #1308

Closed natrem closed 2 years ago

natrem commented 2 years ago

Describe the issue Similar to #1278 I encounter issues when using mockserver-junit-jupiter-no-dependencies. It works fine when using mockserver-junit-jupiter.

Execution logs SLF4J binding issue:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:xxx/.m2/repository/ch/qos/logback/logback-classic/1.2.11/logback-classic-1.2.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:xxx/.m2/repository/org/mock-server/mockserver-junit-jupiter-no-dependencies/5.13.2/mockserver-junit-jupiter-no-dependencies-5.13.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]

Note that I encountered a more blocking issue in professional context but it's more difficult to extract a reproduction and the cause is likely similar:

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.impl.JDK14LoggerFactory loaded from file:xxx/.m2/repository/org/mock-server/mockserver-junit-jupiter-no-dependencies/5.13.2/mockserver-junit-jupiter-no-dependencies-5.13.2.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.slf4j.impl.JDK14LoggerFactory

What you are trying to do My module instantiate a mock server through the junit 5 extension and is relying on logback for logging. The specific test falling is not relying on mockserver but starts a simple spring boot application.

MockServer version 5.13.2

To Reproduce The binding issue is reproduced with:

Idea I did not look for the rational behind the -no-dependencies artifacts, but the issue comes from the shading jar containing all needed materials to run mock-server without external dependency. I'm fine with using the 'standard' dependencies but the documentation indicates the no-dependency ones. The solution may be to simply update the documentation to state the purpose of the different libraries.

I did see the section listing the artifacts (https://mock-server.com/where/maven_central.html) but the choice is not very visible from the main documentation pages.

BTW thanks for your work on this tool.

jamesdbloom commented 2 years ago

This is already fixed in this commit: #2711c33

This is not yet released but will be released in the next few weeks.

veysiertekin commented 2 years ago

Hi @jamesdbloom , thank you for the fix. when do you plan to make a release? this can be really useful for us.

malvarezcastillo commented 2 years ago

Hi @jamesdbloom is there any workaround we can implement until there is a new release? This bug is a blocker for us too.

zoltan-toth-mw commented 1 year ago

@jamesdbloom This is still an issue with mockserver-junit-jupiter-no-dependencies:5.15.0, at least with gradle.

org.mock-server:mockserver-junit-jupiter:5.15.0 works nicely, but the documentation "advertises" the no dependency versions.

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.jul.JDK14LoggerFactory loaded from file:/Users/user/.gradle/caches/modules-2/files-2.1/org.mock-server/mockserver-junit-jupiter-no-dependencies/5.15.0/40fd1649b4faff31363e100994bcb0ece8ead3cc/mockserver-junit-jupiter-no-dependencies-5.15.0.jar).
mgkim-woowahan commented 1 year ago

I have same issue in org.mock-server:mockserver-junit-jupiter-no-dependencies:5.15.0

yurym-ping commented 1 year ago

Same with org.mock-server.mockserver-client-java-no-dependencies:5.15.0

patrickjamesbarry commented 1 week ago

Since this is still happening in 5.15.0, can this ticket be reopened or do we need to create a new ticket?