19

When upgrading my Spring Boot 2.5 to 3.0 , I am facing some issues with Wiremock, probably due to the move to jakarta namespace. Even upgrading to latest wiremock-jre8 , ie 2.35.0 (as of december 2022) doesn't seem to help. I get this error :

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)
Vincent F
  • 6,523
  • 7
  • 37
  • 79

3 Answers3

22

Looks like this is a know issue related to jakarta namespace and Jetty 11 support, that will take a while to get properly fixed :

https://github.com/wiremock/wiremock/issues/1760

As indicated in the issue, using wiremock-jre8-standalone instead of wiremock-jre8 helps working around the issue, until it gets properly fixed in Wiremock 3.x

Vincent F
  • 6,523
  • 7
  • 37
  • 79
2

E.g. Wiremock version 1.58 works (if you don't mind using an older version) in combination with Spring Boot 3

Shakesbeer
  • 71
  • 6
1

You can also use wiremock version 3.0.0-beta2+ to solve the issue. I just tested it.

https://groups.google.com/g/wiremock-user/c/knTaDyBY70Q

Jaime Caffarel
  • 2,401
  • 4
  • 30
  • 42