Ikhlas Alaydi
02/10/2025, 11:41 AMwiremock-spring-boot 3.6
, I got this:
java.lang.NoClassDefFoundError: org/eclipse/jetty/servlet/ServletContextHandler
at com.github.tomakehurst.wiremock.jetty.JettyHttpServerFactory.buildHttpServer(JettyHttpServerFactory.java:28)
at com.github.tomakehurst.wiremock.WireMockServer.<init>(WireMockServer.java:75)
at org.wiremock.spring.internal.WireMockServerCreator.createWireMockServer(WireMockServerCreator.java:93)
at org.wiremock.spring.internal.WireMockContextCustomizer.resolveOrCreateWireMockServer(WireMockContextCustomizer.java:57)
at org.wiremock.spring.internal.WireMockContextCustomizer.customizeContext(WireMockContextCustomizer.java:47)
at org.springframework.boot.test.context.SpringBootContextLoader$ContextCustomizerAdapter.initialize(SpringBootContextLoader.java:435)
at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:607)
at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:387)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:311)
at org.springframework.boot.test.context.SpringBootContextLoader.lambda$loadContext$3(SpringBootContextLoader.java:137)
at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:58)
at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:46)
at org.springframework.boot.SpringApplication.withHook(SpringApplication.java:1406)
at org.springframework.boot.test.context.SpringBootContextLoader$ContextLoaderHook.run(SpringBootContextLoader.java:545)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:137)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:108)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:187)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:119)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:127)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:141)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:97)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:241)
...
I tried to add wiremock-jetty12 dependency, but ran into this
java.lang.NoClassDefFoundError: org/eclipse/jetty/server/ConnectionMetaData at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1023) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150) at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862) at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525) at com.github.tomakehurst.wiremock.jetty11.Jetty11HttpServer.createHttpConnector(Jetty11HttpServer.java:90) at com.github.tomakehurst.wiremock.jetty.JettyHttpServer.<init>(JettyHttpServer.java:79) at com.github.tomakehurst.wiremock.jetty11.Jetty11HttpServer.<init>(Jetty11HttpServer.java:76) at com.github.tomakehurst.wiremock.jetty.JettyHttpServerFactory.buildHttpServer(JettyHttpServerFactory.java:28) at com.github.tomakehurst.wiremock.WireMockServer.<init>(WireMockServer.java:75) at org.wiremock.spring.internal.WireMockServerCreator.createWireMockServer(WireMockServerCreator.java:93) at org.wiremock.spring.internal.WireMockContextCustomizer.resolveOrCreateWireMockServer(WireMockContextCustomizer.java:57)
Last, I tried to force jetty12 and exclude jetty11 but got this
error java.lang.NoClassDefFoundError: org/eclipse/jetty/http/MimeTypes$Mutable at org.eclipse.jetty.server.Server.<init>(Server.java:85) at org.eclipse.jetty.server.Server.<init>(Server.java:141) at com.github.tomakehurst.wiremock.jetty.JettyHttpServer.createServer(JettyHttpServer.java:125) at com.github.tomakehurst.wiremock.jetty.JettyHttpServer.<init>(JettyHttpServer.java:70) at com.github.tomakehurst.wiremock.jetty12.Jetty12HttpServer.<init>(Jetty12HttpServer.java:74) at com.github.tomakehurst.wiremock.jetty12.Jetty12HttpServerFactory.buildHttpServer(Jetty12HttpServerFactory.java:33) at com.github.tomakehurst.wiremock.WireMockServer.<init>(WireMockServer.java:75)
Could you please assist in how to fix this dependencies issue so I can use wiremock smoothly🙏
for reference, Spring Boot version is (v3.1.2)
ThanksLee Turner
02/10/2025, 11:52 AM3.1.2
still uses jetty 11. Are you fixed to that version of Spring Boot or can you upgrade ?Ikhlas Alaydi
02/10/2025, 11:53 AMLee Turner
02/10/2025, 11:56 AMIkhlas Alaydi
02/10/2025, 12:16 PMIkhlas Alaydi
02/10/2025, 12:17 PMLee Turner
02/10/2025, 12:17 PMLee Turner
02/10/2025, 12:18 PMLee Turner
02/10/2025, 12:19 PMLee Turner
02/10/2025, 12:21 PMIkhlas Alaydi
02/10/2025, 12:26 PM