https://linen.dev logo
#help
Title
# help
m

Martin Edgar Albarracin Chinome

02/23/2024, 3:17 PM
Hi all, I'm doing a migration from com.github.tomakehurstwiremock jre8jar2.26.3test to org.wiremock: wiremock: 3.0.0 but I'm having an issue, I'm not able to find any blog related to this issue
Copy code
java.lang.IllegalStateException: Failed to load ApplicationContext for [WebMergedContextConfiguration@47ae6c18 testClass = 

Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletOutputStream
	at java.base/java.lang.Class.getDeclaredFields0(Native Method)
	at java.base/java.lang.Class.privateGetDeclaredFields(Class.java:3297)
	at java.base/java.lang.Class.getDeclaredFields(Class.java:2371)
	at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:727)
	... 50 more
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletOutputStream
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
If I understand well now we are using jakarta instead of javax.
l

Lee Turner

02/23/2024, 4:25 PM
Hi. Are you using spring? If so what version of spring are you using ?
m

Martin Edgar Albarracin Chinome

02/23/2024, 4:26 PM
Hi yes, I'm using 3.1.4
after the migration my tests no longer work I was using
wiremock-jre8:2.35.2
but after I migrated spring to 3.1.4 my tests are not longer work I'm getting this issue with mi initial version 2.35.2
Copy code
java.lang.NoClassDefFoundError: javax/servlet/DispatcherType
according to this github issue, I have to use
com.github.tomakehurst:wiremock-jre8-standalone:2.35.0"
I tested with that version and others but always is getting this issue
Copy code
java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.reflection.ReflectionCache

Exception java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7 [in thread "main"]
seems adding the next library solve that issue
Copy code
org.codehaus.groovygroovy3.0.20
but after that I'm getting
Copy code
Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletOutputStream
the same issue ay the start of this thread 😞
@Tom Any solution or advice for me is welcome. thanks
l

Lee Turner

02/23/2024, 7:18 PM
I am driving at the moment but will try to take a look when I arrive.
t

Tom

02/23/2024, 9:19 PM
I suggest switching to the standalone JAR in the first instance. I think you’ve probably got as javax vs. jakarta servlet clash, and using standalone will avoid this.
l

Lee Turner

02/23/2024, 9:46 PM
@Martin Edgar Albarracin Chinome sorry for the late reply. Been traveling for ages 😥 Tom summed it up with regard to switching to the standalone version of wiremock. This is the standalone version https://mvnrepository.com/artifact/org.wiremock/wiremock-standalone
m

Martin Edgar Albarracin Chinome

02/23/2024, 9:53 PM
Thanks all, I'm using
org.wiremock:wiremock-standalone:3.0.0
but I'm getting the same issue
Copy code
Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletOutputStream
t

Tom

02/23/2024, 9:54 PM
Any reason you can't use 3.4.2?
m

Martin Edgar Albarracin Chinome

02/23/2024, 10:01 PM
Same issue 😞 using 3.4.2
Copy code
<dependency>
  <groupId>org.wiremock</groupId>
  <artifactId>wiremock-standalone</artifactId>
  <version>3.4.2</version>
  <scope>test</scope>
</dependency>
Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletOutputStream
t

Tom

02/24/2024, 10:05 AM
Either this is something outside of WireMock or somehow you’re still getting the thin JAR on the classpath.
m

Martin Edgar Albarracin Chinome

02/26/2024, 12:53 PM
Hi all, thanks for your replies. yes you're right I discovered that one of my libraries was using javax instead of jakarta, after fixed this one I was able to run my project thanks a lot all.
👍 2
96 Views