Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Integration tests failing on pipelines with NoClassDefFoundError

Sunny Agarwal February 27, 2020

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.ContactManagerIntegrationTestjava.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.

2 answers

0 votes
dluga93 September 4, 2021

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.

0 votes
Dmitri Zamysloff July 27, 2020

Hi! Is there any fix for the problem availble?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events