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.57k stars 1.07k forks source link

logback-classic #659

Closed vyom-soft closed 4 years ago

vyom-soft commented 5 years ago

Hi, I followed your example. with following dependency

org.mock-server mockserver-netty 5.6.1
    <dependency>
        <groupId>org.mock-server</groupId>
        <artifactId>mockserver-client-java</artifactId>
        <version>5.6.1</version>
    </dependency>

I get following error, could you please give some insight what is causing this problem.

[main] DEBUG org.mockserver.logging.MockServerLogger - exception while initialising log file please include ch.qos.logback:logback-classic dependency to enable log file support java.lang.NoSuchMethodException: no such method: ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP.setMaxFileSize(String)void/invokeVirtual at java.lang.invoke.MemberName.makeAccessException(MemberName.java:871) at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:1003) at java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:1386) at java.lang.invoke.MethodHandles$Lookup.findVirtual(MethodHandles.java:861) at org.mockserver.logging.MockServerLogger.setLogbackAppender(MockServerLogger.java:115) at org.mockserver.logging.MockServerLogger.initialiseLogLevels(MockServerLogger.java:40) at org.mockserver.logging.MockServerLogger.(MockServerLogger.java:34) at org.mockserver.client.MockServerClient.(MockServerClient.java:43) at org.mockserver.integration.ClientAndServer.(ClientAndServer.java:18) at org.mockserver.integration.ClientAndServer.startClientAndServer(ClientAndServer.java:30) at TestMyMockServer.startServer(TestMyMockServer.java:21) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:532) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:115) at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.lambda$invokeBeforeAllMethods$5(ClassTestDescriptor.java:228) at org.junit.jupiter.engine.execution.ThrowableCollector.execute(ThrowableCollector.java:40) at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.invokeBeforeAllMethods(ClassTestDescriptor.java:227) at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.before(ClassTestDescriptor.java:151) at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.before(ClassTestDescriptor.java:61) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$4(NodeTestTask.java:105) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:98) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:74) at java.util.ArrayList.forEach(ArrayList.java:1257) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$4(NodeTestTask.java:112) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:98) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:74) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220) at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188) at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) Caused by: java.lang.NoSuchMethodError: ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP.setMaxFileSize(Ljava/lang/String;)V at java.lang.invoke.MethodHandleNatives.resolve(Native Method) at java.lang.invoke.MemberName$Factory.resolve(MemberName.java:975) at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:1000) ... 42 common frames omitted

best regards Sanjeev

CSBaum commented 4 years ago

I am also having the same problem.

Just to cover my bases i tried adding the logback-core and logback-classic dependencies to my build and that hasn't resolved the issue.

brennantaylor commented 4 years ago

The issue is ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP.setMaxFileSize(String)void/invokeVirtual

That method no longer exists. This is the commit that changed the signature to accept a FileSize object instead of a String: https://github.com/qos-ch/logback/commit/03e26684d43066d53dbf926e060a73d43bee77fd#diff-e4b96cdb9893b8af380b621b376dee53

Browsing the files it likely got released as part of logback classic 1.1.8.

I had to force both classic and core to 1.1.7 and the error went away. mockserver should be updated to call the right methods though.

// gradle kotlin dsl
testImplementation("ch.qos.logback:logback-classic:1.1.7") {
  isForce = true
}
testImplementation("ch.qos.logback:logback-core:1.1.7") {
  isForce = true
}
heathen00 commented 4 years ago

I've hit this issue, too.

jamesdbloom commented 4 years ago

I have now simplified the logging usage significantly, and in fact, I had previously done some simplifications, so it no longer seemed valuable to use a more complex logging framework like logback. The MockServer now uses Java Logger under the hood, but the SLF4J binding is marked as optional in the pom.xml so ultimately it'll use anything available to SLF4J if it's on the classpath.

This change should resolve this issue and hopefully simplify the configuration going forward. No additional none JDK logging frameworks are now used, except SLF4J and its binding to Java Logger (which is optional).

jamesdbloom commented 4 years ago

I will release a new version with this fix within the next week.