wiremock / wiremock

A tool for mocking HTTP services
https://wiremock.org/
Apache License 2.0
6.39k stars 1.44k forks source link

Wiremock does not work with Spring Boot 3.0.0 #1928

Closed kkocel closed 2 months ago

kkocel commented 2 years ago

Hi, I would like to highlight an issue that I found out about today:

when using id("org.springframework.boot") version "3.0.0-M4"

I noticed that those imports are not present in JettyHttpServer

import javax.servlet.DispatcherType;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

causing Wiremock to fail on startup.

kkocel commented 2 years ago

Dependency resolution (from Gradle):

+--- com.github.tomakehurst:wiremock-jre8:2.33.2
|    +--- org.eclipse.jetty:jetty-bom:9.4.46.v20220331
|    |    +--- org.eclipse.jetty:jetty-alpn-java-client:9.4.46.v20220331 -> 11.0.11 (c)
|    |    +--- org.eclipse.jetty:jetty-alpn-java-server:9.4.46.v20220331 -> 11.0.11 (c)
|    |    +--- org.eclipse.jetty:jetty-alpn-openjdk8-client:9.4.46.v20220331 (c)
|    |    +--- org.eclipse.jetty:jetty-alpn-openjdk8-server:9.4.46.v20220331 (c)
|    |    +--- org.eclipse.jetty:jetty-alpn-server:9.4.46.v20220331 -> 11.0.11 (c)
|    |    +--- org.eclipse.jetty.http2:http2-server:9.4.46.v20220331 -> 11.0.11 (c)
|    |    +--- org.eclipse.jetty:jetty-proxy:9.4.46.v20220331 -> 11.0.11 (c)
|    |    +--- org.eclipse.jetty:jetty-server:9.4.46.v20220331 -> 11.0.11 (c)
|    |    +--- org.eclipse.jetty:jetty-servlet:9.4.46.v20220331 -> 11.0.11 (c)
|    |    +--- org.eclipse.jetty:jetty-servlets:9.4.46.v20220331 -> 11.0.11 (c)
|    |    +--- org.eclipse.jetty:jetty-webapp:9.4.46.v20220331 -> 11.0.11 (c)
|    |    +--- org.eclipse.jetty:jetty-http:9.4.46.v20220331 -> 11.0.11 (c)
|    |    +--- org.eclipse.jetty:jetty-io:9.4.46.v20220331 -> 11.0.11 (c)
|    |    +--- org.eclipse.jetty:jetty-security:9.4.46.v20220331 -> 11.0.11 (c)
|    |    +--- org.eclipse.jetty:jetty-util:9.4.46.v20220331 -> 11.0.11 (c)
|    |    +--- org.eclipse.jetty:jetty-xml:9.4.46.v20220331 -> 11.0.11 (c)
|    |    +--- org.eclipse.jetty:jetty-client:9.4.46.v20220331 -> 11.0.11 (c)
|    |    +--- org.eclipse.jetty.http2:http2-common:9.4.46.v20220331 -> 11.0.11 (c)
|    |    +--- org.eclipse.jetty:jetty-alpn-client:9.4.46.v20220331 -> 11.0.11 (c)
|    |    \--- org.eclipse.jetty.http2:http2-hpack:9.4.46.v20220331 -> 11.0.11 (c)
|    +--- org.eclipse.jetty:jetty-server -> 11.0.11
|    |    +--- org.eclipse.jetty.toolchain:jetty-jakarta-servlet-api:5.0.2
|    |    +--- org.eclipse.jetty:jetty-http:11.0.11
|    |    |    +--- org.eclipse.jetty:jetty-util:11.0.11
|    |    |    |    \--- org.slf4j:slf4j-api:2.0.0-alpha6 -> 1.7.36
|    |    |    +--- org.eclipse.jetty:jetty-io:11.0.11
|    |    |    |    +--- org.slf4j:slf4j-api:2.0.0-alpha6 -> 1.7.36
|    |    |    |    \--- org.eclipse.jetty:jetty-util:11.0.11 (*)
|    |    |    \--- org.slf4j:slf4j-api:2.0.0-alpha6 -> 1.7.36
|    |    +--- org.eclipse.jetty:jetty-io:11.0.11 (*)
|    |    \--- org.slf4j:slf4j-api:2.0.0-alpha6 -> 1.7.36
|    +--- org.eclipse.jetty:jetty-servlet -> 11.0.11
|    |    +--- org.eclipse.jetty:jetty-security:11.0.11
|    |    |    +--- org.eclipse.jetty:jetty-server:11.0.11 (*)
|    |    |    \--- org.slf4j:slf4j-api:2.0.0-alpha6 -> 1.7.36
|    |    \--- org.slf4j:slf4j-api:2.0.0-alpha6 -> 1.7.36
|    +--- org.eclipse.jetty:jetty-servlets -> 11.0.11
|    |    +--- org.eclipse.jetty:jetty-http:11.0.11 (*)
|    |    +--- org.eclipse.jetty:jetty-util:11.0.11 (*)
|    |    +--- org.eclipse.jetty:jetty-io:11.0.11 (*)
|    |    \--- org.slf4j:slf4j-api:2.0.0-alpha6 -> 1.7.36
|    +--- org.eclipse.jetty:jetty-webapp -> 11.0.11
|    |    +--- org.eclipse.jetty:jetty-servlet:11.0.11 (*)
|    |    +--- org.eclipse.jetty:jetty-xml:11.0.11
|    |    |    +--- org.eclipse.jetty:jetty-util:11.0.11 (*)
|    |    |    \--- org.slf4j:slf4j-api:2.0.0-alpha6 -> 1.7.36
|    |    \--- org.slf4j:slf4j-api:2.0.0-alpha6 -> 1.7.36
|    +--- org.eclipse.jetty:jetty-proxy -> 11.0.11
|    |    +--- org.slf4j:slf4j-api:2.0.0-alpha6 -> 1.7.36
|    |    +--- org.eclipse.jetty:jetty-util:11.0.11 (*)
|    |    \--- org.eclipse.jetty:jetty-client:11.0.11
|    |         +--- org.eclipse.jetty:jetty-http:11.0.11 (*)
|    |         +--- org.eclipse.jetty:jetty-io:11.0.11 (*)
|    |         +--- org.eclipse.jetty:jetty-alpn-client:11.0.11
|    |         |    +--- org.eclipse.jetty:jetty-io:11.0.11 (*)
|    |         |    \--- org.slf4j:slf4j-api:2.0.0-alpha6 -> 1.7.36
|    |         \--- org.slf4j:slf4j-api:2.0.0-alpha6 -> 1.7.36
|    +--- org.eclipse.jetty.http2:http2-server -> 11.0.11
|    |    +--- org.eclipse.jetty.http2:http2-common:11.0.11
|    |    |    +--- org.eclipse.jetty.http2:http2-hpack:11.0.11
|    |    |    |    +--- org.eclipse.jetty:jetty-util:11.0.11 (*)
|    |    |    |    +--- org.eclipse.jetty:jetty-http:11.0.11 (*)
|    |    |    |    +--- org.eclipse.jetty:jetty-io:11.0.11 (*)
|    |    |    |    \--- org.slf4j:slf4j-api:2.0.0-alpha6 -> 1.7.36
|    |    |    \--- org.slf4j:slf4j-api:2.0.0-alpha6 -> 1.7.36
|    |    +--- org.eclipse.jetty:jetty-server:11.0.11 (*)
|    |    \--- org.slf4j:slf4j-api:2.0.0-alpha6 -> 1.7.36
|    +--- org.eclipse.jetty:jetty-alpn-server -> 11.0.11
|    |    +--- org.eclipse.jetty:jetty-server:11.0.11 (*)
|    |    \--- org.slf4j:slf4j-api:2.0.0-alpha6 -> 1.7.36
|    +--- org.eclipse.jetty:jetty-alpn-java-server -> 11.0.11
|    |    +--- org.eclipse.jetty:jetty-io:11.0.11 (*)
|    |    +--- org.eclipse.jetty:jetty-alpn-server:11.0.11 (*)
|    |    \--- org.slf4j:slf4j-api:2.0.0-alpha6 -> 1.7.36
|    +--- org.eclipse.jetty:jetty-alpn-openjdk8-server -> 9.4.46.v20220331
|    |    +--- org.eclipse.jetty:jetty-alpn-server:9.4.46.v20220331 -> 11.0.11 (*)
|    |    \--- org.eclipse.jetty:jetty-io:9.4.46.v20220331 -> 11.0.11 (*)
|    +--- org.eclipse.jetty:jetty-alpn-java-client -> 11.0.11
|    |    +--- org.eclipse.jetty:jetty-alpn-client:11.0.11 (*)
|    |    \--- org.slf4j:slf4j-api:2.0.0-alpha6 -> 1.7.36
|    +--- org.eclipse.jetty:jetty-alpn-openjdk8-client -> 9.4.46.v20220331
|    |    \--- org.eclipse.jetty:jetty-alpn-client:9.4.46.v20220331 -> 11.0.11 (*)
|    +--- com.google.guava:guava:31.1-jre
|    |    +--- com.google.guava:failureaccess:1.0.1
|    |    +--- com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
|    |    +--- com.google.code.findbugs:jsr305:3.0.2
|    |    +--- org.checkerframework:checker-qual:3.12.0
|    |    +--- com.google.errorprone:error_prone_annotations:2.11.0
|    |    \--- com.google.j2objc:j2objc-annotations:1.3
|    +--- com.fasterxml.jackson:jackson-bom:2.13.2.20220328 -> 2.13.3 (*)
|    +--- com.fasterxml.jackson.core:jackson-core -> 2.13.3 (*)
|    +--- com.fasterxml.jackson.core:jackson-annotations -> 2.13.3 (*)
|    +--- com.fasterxml.jackson.core:jackson-databind -> 2.13.3 (*)
|    +--- org.apache.httpcomponents.client5:httpclient5:5.1.3
|    |    +--- org.apache.httpcomponents.core5:httpcore5:5.1.3 -> 5.1.4
|    |    +--- org.apache.httpcomponents.core5:httpcore5-h2:5.1.3 -> 5.1.4
|    |    |    \--- org.apache.httpcomponents.core5:httpcore5:5.1.4
|    |    +--- org.slf4j:slf4j-api:1.7.25 -> 1.7.36
|    |    \--- commons-codec:commons-codec:1.15
|    +--- org.xmlunit:xmlunit-core:2.9.0
|    +--- org.xmlunit:xmlunit-legacy:2.9.0
|    |    \--- org.xmlunit:xmlunit-core:2.9.0
|    +--- org.xmlunit:xmlunit-placeholders:2.9.0
|    |    \--- org.xmlunit:xmlunit-core:2.9.0
|    +--- net.javacrumbs.json-unit:json-unit-core:2.33.0
|    |    \--- org.hamcrest:hamcrest-core:2.2
|    |         \--- org.hamcrest:hamcrest:2.2
|    +--- com.jayway.jsonpath:json-path:2.7.0 (*)
|    +--- org.ow2.asm:asm:9.3
|    +--- org.slf4j:slf4j-api:1.7.36
|    +--- net.sf.jopt-simple:jopt-simple:5.0.4
|    +--- org.apache.commons:commons-lang3:3.12.0
|    +--- com.github.jknack:handlebars:4.3.0
|    |    \--- org.slf4j:slf4j-api:1.7.32 -> 1.7.36
|    +--- com.github.jknack:handlebars-helpers:4.3.0
|    |    +--- com.github.jknack:handlebars:4.3.0 (*)
|    |    \--- org.apache.commons:commons-lang3:3.12.0
|    +--- commons-fileupload:commons-fileupload:1.4
|    \--- commons-io:commons-io:2.11.0
FrostbittenKing commented 2 years ago

Yeah, I just discovered this too. I was checking the necessary steps in our project to prepare for the spring boot 3.0 release, and unfortunately, wiremock still builds with java 8 (for whatever reason), and when I checked, I saw it had the dependency to an old jetty version - v9.x(I think the most recent version is at least 11, which uses the corresponding jakarta.* libs).

kkocel commented 2 years ago

Dunno if it should be closed in favour of #1760

FrostbittenKing commented 2 years ago

Dunno if it should be closed in favour of #1760

As long as the other ticket picks up speed soon. The other issue is open since January. How can Java11 still be a problem to some projects. I mean the next lts (java 17) was already released, and Java 11 is already pretty old. It isn't that complicated to migrate to java 11.

GregoireW commented 2 years ago

You can switch temporary to the wiremock-jre8-standalone it is an uber jar with dependencies package renamed except for a few of them. It should be ok for most application.

kkocel commented 2 years ago

@GregoireW the problem with the standalone version is that it crashes on logging - there is a conflict with a logback from Spring Boot:

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:/Users/user/.gradle/caches/modules-2/files-2.1/com.github.tomakehurst/wiremock-jre8-standalone/2.27.2/2f514e3a141617f0f4d32d272a07c0ab8fb8054e/wiremock-jre8-standalone-2.27.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.helpers.NOPLoggerFactory

GregoireW commented 2 years ago

@kkocel try to upgrade wiremock to to 2.35.0 on a SpringBoot 3.0.0 application it works on my end (I got a small app, so not a lot of possible conflict. but at least logs is working)

davinkevin commented 2 years ago

I had to use the standalone java in version 2.35.0

The standard jar had the same problem for me:


javax/servlet/DispatcherType
java.lang.NoClassDefFoundError: javax/servlet/DispatcherType
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:375)
    at com.github.tomakehurst.wiremock.jetty9.JettyHttpServerFactory.getServerConstructor(JettyHttpServerFactory.java:37)
    at com.github.tomakehurst.wiremock.jetty9.JettyHttpServerFactory.<clinit>(JettyHttpServerFactory.java:30)
    at com.github.tomakehurst.wiremock.core.WireMockConfiguration.<init>(WireMockConfiguration.java:94)
    at com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig(WireMockConfiguration.java:135)
    at com.github.tomakehurst.wiremock.WireMockServer.<init>(WireMockServer.java:117)
    at com.github.davinkevin.podcastserver.MockS3Server.beforeAll(PodcastServerApplicationTests.kt:36)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeBeforeAllCallbacks$12(ClassBasedTestDescriptor.java:395)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeBeforeAllCallbacks(ClassBasedTestDescriptor.java:395)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:211)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:84)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:148)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:99)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
    at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
    at jdk.proxy2/jdk.proxy2.$Proxy5.stop(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:193)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
    at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
    at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133)
    at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
    at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
    at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
    Suppressed: kotlin.UninitializedPropertyAccessException: lateinit property server has not been initialized
        at com.github.davinkevin.podcastserver.MockS3Server.afterAll(PodcastServerApplicationTests.kt:43)
        at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeAfterAllCallbacks$18(ClassBasedTestDescriptor.java:461)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeAfterAllCallbacks$19(ClassBasedTestDescriptor.java:461)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeAfterAllCallbacks(ClassBasedTestDescriptor.java:461)
        at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.after(ClassBasedTestDescriptor.java:235)
        at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.after(ClassBasedTestDescriptor.java:84)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:161)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:161)
        ... 47 more
Caused by: java.lang.ClassNotFoundException: javax.servlet.DispatcherType
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    ... 63 more
sumanmaity112 commented 2 years ago

I am also having the same issue even with wiremock-jre8:2.35.0

myashchenko commented 2 years ago

Same here

wk-tw commented 1 year ago

Same here

lhenriquegomescamilo commented 1 year ago

I had to use the standalone java in version 2.35.0

The standard jar had the same problem for me:


javax/servlet/DispatcherType
java.lang.NoClassDefFoundError: javax/servlet/DispatcherType
  at java.base/java.lang.Class.forName0(Native Method)
  at java.base/java.lang.Class.forName(Class.java:375)
  at com.github.tomakehurst.wiremock.jetty9.JettyHttpServerFactory.getServerConstructor(JettyHttpServerFactory.java:37)
  at com.github.tomakehurst.wiremock.jetty9.JettyHttpServerFactory.<clinit>(JettyHttpServerFactory.java:30)
  at com.github.tomakehurst.wiremock.core.WireMockConfiguration.<init>(WireMockConfiguration.java:94)
  at com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig(WireMockConfiguration.java:135)
  at com.github.tomakehurst.wiremock.WireMockServer.<init>(WireMockServer.java:117)
  at com.github.davinkevin.podcastserver.MockS3Server.beforeAll(PodcastServerApplicationTests.kt:36)
  at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeBeforeAllCallbacks$12(ClassBasedTestDescriptor.java:395)
  at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
  at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeBeforeAllCallbacks(ClassBasedTestDescriptor.java:395)
  at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:211)
  at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:84)
  at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:148)
  at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
  at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
  at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
  at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
  at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
  at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
  at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
  at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
  at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
  at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
  at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
  at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
  at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
  at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
  at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
  at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
  at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
  at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
  at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
  at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
  at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
  at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
  at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
  at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
  at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
  at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
  at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
  at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:99)
  at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79)
  at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75)
  at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.base/java.lang.reflect.Method.invoke(Method.java:568)
  at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
  at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
  at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
  at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
  at jdk.proxy2/jdk.proxy2.$Proxy5.stop(Unknown Source)
  at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:193)
  at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
  at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
  at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
  at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
  at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133)
  at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
  at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
  at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
  Suppressed: kotlin.UninitializedPropertyAccessException: lateinit property server has not been initialized
      at com.github.davinkevin.podcastserver.MockS3Server.afterAll(PodcastServerApplicationTests.kt:43)
      at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeAfterAllCallbacks$18(ClassBasedTestDescriptor.java:461)
      at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
      at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeAfterAllCallbacks$19(ClassBasedTestDescriptor.java:461)
      at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
      at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeAfterAllCallbacks(ClassBasedTestDescriptor.java:461)
      at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.after(ClassBasedTestDescriptor.java:235)
      at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.after(ClassBasedTestDescriptor.java:84)
      at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:161)
      at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
      at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:161)
      ... 47 more
Caused by: java.lang.ClassNotFoundException: javax.servlet.DispatcherType
  at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
  at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
  at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
  ... 63 more

I have same problem!

tomakehurst commented 1 year ago

Has anyone had a chance to test this with 3.0.0-beta-4?

luisalves00 commented 1 year ago

@tomakehurst swtiched to testImplementation("org.springframework.cloud:spring-cloud-starter-contract-stub-runner") as described on https://wiremock.org/docs/spring-boot/

tomakehurst commented 1 year ago

Pretty sure that's still 2.x

luisalves00 commented 1 year ago

@tomakehurst now I get that you are asking for wiremock version. This combination works:

implementation("org.springframework.boot:spring-boot-dependencies:3.0.4") testImplementation("com.github.tomakehurst:wiremock-jre8-standalone:2.35.0")

didn't test with wiremock 3.0.0-beta-4 still

abhisheksr01 commented 1 year ago

I was also getting java.lang.NoClassDefFoundError: javax/servlet/DispatcherType error after bumping spring-boot and java.

But I can confirm it works with the below versions: :smiley: :smiley: Wiremock - 3.0.0-beta-4 Java - 17 Springboot - 3.0.5 Gradle - 7.6.1

Here is the link to my build.gradle and the repo for reference. https://github.com/abhisheksr01/spring-boot-microservice-best-practices/blob/master/build.gradle

bhavyaSharma-appD commented 1 year ago

@GregoireW the problem with the standalone version is that it crashes on logging - there is a conflict with a logback from Spring Boot:

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:/Users/user/.gradle/caches/modules-2/files-2.1/com.github.tomakehurst/wiremock-jre8-standalone/2.27.2/2f514e3a141617f0f4d32d272a07c0ab8fb8054e/wiremock-jre8-standalone-2.27.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.helpers.NOPLoggerFactory

I am also getting this logging issue. Is there a way to solve this?

GregoireW commented 1 year ago

@bhavyaSharma-appD (I'm not a wiremock maintainer so i speak only from what I observe) There is a wiremock 3.0 beta version which solve mains of the problem on springboot3 (the artifactID is back to wiremock) . (current version : com.github.tomakehurst :: wiremock :: 3.0.0-beta-8 )

oleg-nenashev commented 1 year ago

This is right, WireMock 3x is updated accordingly.

Bas83 commented 1 year ago

Hi there! And what is the expected release date for WireMock 3.x? Our upgrade is currently also blocked by this, since we depend on a library (bakdata fluent kafka streams tests) that uses the old version.

du-it commented 1 year ago

Migrating form Spring Boot 2.7.12 to 3.x my tests using WirekMockServer working so far don't do that anymore (neither with wiremock-standalone version 2.27.2 nor with 3.0.0-beta-10). Now, tests always return a 500 INTERNAL_SERVER_ERROR instead of a 200 or 401 or ... What can be the reason for?

tomakehurst commented 1 year ago

@du-it can I suggest you head over to the WireMock Slack and post the details of what you're seeing?

du-it commented 1 year ago

Would you please invite me?

tomakehurst commented 1 year ago

You can just head to https://slack.wiremock.org

jwedel commented 12 months ago

So weirdly, this was working until Spring boot 3.1.6. With Spring Boot 3.2 and wiremock 3.0.1 it starts breaking with the missing DispatcherType. So curretnly we needed to revert to the previous spring boot version.

GregoireW commented 12 months ago

@jwedel the issue is decribed here with a workaround: https://github.com/wiremock/wiremock/issues/2395

kkocel commented 12 months ago

@jwedel you can use standalone dependency in your test - this will make you independent from spring dependencies:

<dependency>
    <groupId>org.wiremock</groupId>
    <artifactId>wiremock-standalone</artifactId>
    <version>3.3.1</version>
    <scope>test</scope>
</dependency> 
leeturner commented 2 months ago

Closing this as we now have WireMock jetty 12 for Spring Boot 3.x compatibility - https://wiremock.org/docs/jetty-12/