3 Replies Latest reply on Feb 24, 2017 6:57 AM by Bartosz Majsak

    Arquillian and Cobertura: 0% percent coverage or ClassNotFoundException

    Gerrit Hohl Newbie

      Hello everyone,

       

      I have a working Arquillian based WildFly test within a Maven build. And now I want to add Cobertura coverage tests.

       

      But it seems it isn't easy: If I just include the Cobertura Maven plugin my build fails because every class has a coverage of 0%, the tests are marked as "Error" (only during the Cobertura test execution, the normal test execution works without any problems)  and I get the following error in the console:

      java.lang.NoClassDefFoundError: net/sourceforge/cobertura/coveragedata/TouchCollector
      Caused by: java.lang.ClassNotFoundException: net.sourceforge.cobertura.coveragedata.TouchCollector from [Module "deployment.91f93bde-a5de-4cd1-a8e4-d1174885713f.war:main" from Service Module Loader]
      

       

      And if I add the Cobertura library to the deployment, I get the following error at the end of the complete testing:

      Exception in thread "Thread-94" java.lang.NoClassDefFoundError: net/sourceforge/cobertura/coveragedata/ClassData
          at net.sourceforge.cobertura.coveragedata.ProjectData.getOrCreateClassData(ProjectData.java:88)
          at net.sourceforge.cobertura.coveragedata.TouchCollector.applyTouchesOnProjectData(TouchCollector.java:109)
          at net.sourceforge.cobertura.coveragedata.ProjectData.saveGlobalProjectData(ProjectData.java:272)
          at net.sourceforge.cobertura.coveragedata.SaveTimer.run(SaveTimer.java:33)
          at java.lang.Thread.run(Thread.java:745)
      Caused by: java.lang.ClassNotFoundException: net.sourceforge.cobertura.coveragedata.ClassData from [Module "deployment.10d71cf1-6f23-46b2-9295-dd93eb249f3f.war:main" from Service Module Loader]
          at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
          at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
          at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
          at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
          ... 5 more
      

      Then I get a coverage rate. But it is very ugly and the next colleague stumbling across this message will try to fix it.

       

      Is there a way to fix that problem?

      I guess it's about the different class loaders and that the inner Cobertura library tries to communicate with the outer Cobertura library. But I have no clue how to solve something like that.