I have a kotlin spring boot app with junit5 tests and gradle as build tool. There are some unit tests and some integration tests. Everything works fine on my local machine with all tests passing. But when I run them on pipeline, the unit tests are passing but integration tests are failing with java.lang.NoClassDefFoundError which seems quite weird.
java.lang.NoClassDefFoundError: Could not initialize class com.xxx.xxx.manager.ContactManagerIntegrationTest
java.lang.NoClassDefFoundError: Could not initialize class com.xxx.xxx.manager.ContactManagerIntegrationTest
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.junit.platform.commons.util.ReflectionUtils.newInstance(ReflectionUtils.java:500)
at org.junit.jupiter.engine.execution.ConstructorInvocation.proceed(ConstructorInvocation.java:56)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:125)
at org.junit.jupiter.api.extension.InvocationInterceptor.interceptTestClassConstructor(InvocationInterceptor.java:69)
at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:104)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:62)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:43)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:35)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:77)
I am using `adoptopenjdk/openjdk11` as the bitbucket pipeline image. I am not sure how to go about debugging this problem.
I had a similar issue but not quite the same. I will put the answer here since google shows this post when searching for my issue too.
I have a java spring boot application with maven as a build tool. The issue happened on unit tests not integration tests.
The tests worked fine when I ran them locally, but they failed on bitbucket pipelines. The error was similar to yours:
java.lang.NoClassDefFoundError: Could not initialize class MockClassThatIUseInTests
I noticed that the maven version I was using locally was 3.6.0, while the one defined in the bitbucket pipeline file was 3.6.3. I changed the pipeline to use 3.6.0 and the tests succeeded.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.