https://linen.dev logo
#wiremock-java
Title
# wiremock-java
e

Emmanuel Godwin

12/02/2023, 9:09 AM
I upgraded a demo Spring application spring: 3.1.4 => 3.2.0 spring-cloud: 2022.0.4 => 2023.0.0-RC1 java 17 => 21 wiremock => 3.3.1
Copy code
testImplementation ('org.springframework.cloud:spring-cloud-starter-contract-stub-runner') {
    exclude group: 'com.github.tomakehurst', module: 'wiremock-jre8-standalone'
 }
My tests are failing with this error
Copy code
ApplicationTests > initializationError FAILED
 java.lang.IncompatibleClassChangeError: class org.eclipse.jetty.http2.server.HttpChannelOverHTTP2 has interface org.eclipse.jetty.server.HttpChannel as super class
 at java.base/java.lang.ClassLoader.defineClass1(Native Method)
 at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1027)
 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:526)
 .
 .
 .
Please what could be the cause of this error and how can I fix it?
o

Oleg Nenashev

12/02/2023, 11:24 AM
I suspect your updated to Jetty 12 as a transitive dependency. At the moment we distribute with Jetty 11, one may expect such compatibility issues. I think it would be better if we ship an experimental Jetty 12 extension answer the comment away to exclude Jetty 11 (or ship a headless WireMock distro) @Tom
l

Lee Turner

12/02/2023, 4:57 PM
@Emmanuel Godwin have you tried switching to the standalone WireMock JAR in your dependencies ?
o

Oleg Nenashev

12/02/2023, 5:01 PM
@Lee Turner it is already a standalone one but a 2.x one. Updating to 3.x might help but I doubt that
l

Lee Turner

12/02/2023, 5:03 PM
Yeah, I wasn’t sure either. I saw the jre-8 stand-alone but noticed it was part of the exclude group
e

Emmanuel Godwin

12/02/2023, 7:40 PM
@Oleg Nenashev How do I reflect the 2.x => 3.x update in the build?
l

Lee Turner

12/02/2023, 8:57 PM
You can add the latest wiremock standalone to your build as a normal dependency. You need
wiremock-standalone
as the artifactId and
3.3.1
as the version
e

Emmanuel Godwin

12/03/2023, 2:36 PM
@Lee Turner It worked! Thanks.
👍 1
l

Lee Turner

12/03/2023, 5:08 PM
Awesome stuff. 👍
e

Emmanuel Godwin

12/04/2023, 1:58 AM
I was thinking. What could be done so that everything works automatically by just including the stub runner in the spring application?
l

Lee Turner

12/04/2023, 8:13 AM
I think like Oleg mentioned, we will have to release a wiremock version with the updated jetty dependency
e

Emmanuel Godwin

12/04/2023, 8:24 AM
Oh I see. Alright then.
a

alex watts

12/13/2023, 1:05 PM
I'm sure you are way ahead of me. But just in case it can help anyone to build the extension, or for reference, or anything else, I've found this branch for which I've stabilised all of the tests with Jetty12 very useful for Spring Boot 3.2.0 upgrade work, avoiding a need for standalone wiremock, which is working well, at least for my needs. This this guide for Jetty 12 migration was helpful to me. This is the branch https://github.com/alexwatts/wiremock/tree/jetty-12-alpha
🙌 3
👀 1
t

Tom

12/14/2023, 9:57 AM
Thanks for sharing this @alex watts!
🙏 1
😊 1
36 Views