Domanda

I am using the latest Cobertura 2.0 jar, and have done the setup as defined here https://stackoverflow.com/a/5319237/870392.

After executing my test cases when I try to shutdown tomcat (ver 7) to collect the coverage data I get the following error:

Exception in thread "Thread-2" java.lang.NoClassDefFoundError: net/sourceforge/cobertura/coveragedata/TouchCollector$ApplyToClassDataLightClassmapListener
        at net.sourceforge.cobertura.coveragedata.TouchCollector.applyTouchesToSingleClassOnProjectData(TouchCollector.java:70)
        at net.sourceforge.cobertura.coveragedata.TouchCollector.applyTouchesOnProjectData(TouchCollector.java:58)
        at net.sourceforge.cobertura.coveragedata.ProjectData.saveGlobalProjectData(ProjectData.java:324)
        at net.sourceforge.cobertura.coveragedata.SaveTimer.run(SaveTimer.java:34)
        at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ClassNotFoundException: net.sourceforge.cobertura.coveragedata.TouchCollector$ApplyToClassDataLightClassmapListener
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
        ... 5 more

Some additional observations

  1. The referenced class is present in the Cobertura jar file.

  2. The missing class is a static nested class cobertura github code

  3. There was a bug reference related to this for earlier cobertura release 3 March 2010, 1.9.4.1

Any quick fixes which I can do to and then rebuild cobertura from source to fix this?

UPDATE:

On further trial and error, it looks like something to do with shutdown hooks. Instead of WEB-INF/lib I moved the cobertura.jar to tomcat7/lib which means the jar is now available till a later point during tomcat shutdown. As a result the previous Cobertura NoClassDef error is gone, but I get NoClassDef errors for classes within my application (presumably as cobertura starts trying to write the coverage data for each of the classes). The cobertura thread crashes and the ser file is not updated.

È stato utile?

Soluzione

I think this is an issue in Cobertura:

https://github.com/cobertura/cobertura/issues/180

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top