I upgraded a demo Spring application spring: 3.1.4...
# wiremock-java
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?
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
@Emmanuel Godwin have you tried switching to the standalone WireMock JAR in your dependencies ?
@Lee Turner it is already a standalone one but a 2.x one. Updating to 3.x might help but I doubt that
Yeah, I wasn’t sure either. I saw the jre-8 stand-alone but noticed it was part of the exclude group
@Oleg Nenashev How do I reflect the 2.x => 3.x update in the build?
You can add the latest wiremock standalone to your build as a normal dependency. You need
as the artifactId and
as the version
@Lee Turner It worked! Thanks.
👍 1
Awesome stuff. 👍
I was thinking. What could be done so that everything works automatically by just including the stub runner in the spring application?
I think like Oleg mentioned, we will have to release a wiremock version with the updated jetty dependency
Oh I see. Alright then.
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
Thanks for sharing this @alex watts!
🙏 1
😊 1