Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Caused by: java.lang.NoClassDefFoundError: com_atlassian_clover/TestNameSniffer

Getting below error on invoking TestNG unit test cases with clover profile enabled. Did not change any clover version. Not getting any clue why its happening.

Here is my libs details - clover-4.0.3, testng - 6.0.1, maven 3

Caused by: java.lang.NoClassDefFoundError: com_atlassian_clover/TestNameSniffer
at com.mds404.catalog.infrastructure.entity.ModelBase.<clinit>(ModelBase.java:27)
at sun.reflect.GeneratedSerializationConstructorAccessor1.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator.newInstance(SunReflectionFactoryInstantiator.java:40)
at org.objenesis.ObjenesisBase.newInstance(ObjenesisBase.java:59)
at org.mockito.internal.creation.jmock.ClassImposterizer.createProxy(ClassImposterizer.java:111)
at org.mockito.internal.creation.jmock.ClassImposterizer.imposterise(ClassImposterizer.java:51)
at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:52)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:41)
at org.mockito.Mockito.mock(Mockito.java:1014)
at org.mockito.Mockito.mock(Mockito.java:909)
at com.mds404.rest.v2.controller.BaseControllerTest.<init>(BaseControllerTest.java:107)
... 33 more
Caused by: java.lang.ClassNotFoundException: com_atlassian_clover.TestNameSniffer
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.apache.maven.surefire.booter.IsolatedClassLoader.loadClass(IsolatedClassLoader.java:97)
... 46 more
like image 679
mds404 Avatar asked Jan 17 '17 17:01

mds404


1 Answers

The error

Caused by: java.lang.NoClassDefFoundError: com_atlassian_clover/TestNameSniffer

means that the Clover JAR (com.atlassian.clover:clover) is missing on the class path.

This is usually caused by two issues:

  1. Missing com.atlassian.clover:clover dependency. Please note that the Clover Maven Plugin adds this dependency to the project automatically (during the build). However, in some cases, you have to add this dependency manually to other Maven plugins - usually to those which fork new JVM - for instance for in-container tests.

  2. Build is running with Clover disabled but still failing on this error. This usually happens if you run the build with Clover enabled via 'clover:setup' and next install (or deploy) JARs created. When you run your build again, but this time with Clover disabled, the build can fetch these JARs from your ~/.m2 cache. As these JARs contain instrumented code and com.atlassian.clover:clover is missing, build will fail. To solve this problem, clean up your ~/.m2 cache and don't use "clover:setup" with "install" or "deploy".

Reference:

  • https://confluence.atlassian.com/cloverkb/noclassdeffounderror-com_atlassian_clover-coveragerecorder-317196439.html

Cheers Marek

like image 184
Marek Avatar answered Oct 03 '22 08:10

Marek