6

We had installed version of our applications (without any instrumentation or cobertura jar included before generating application bundles).

After installation we instrumented all the jar with cobertura, and included cobertura jar file in java classpath. but while starting application it give below error.

any input will really help, thanks.

Java version "1.7.0_25"
cobertura ver 1.9.4.1

Exception in thread "main" java.lang.NoClassDefFoundError: net/sourceforge/cobertura/coveragedata/HasBeenInstrumented
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: net.sourceforge.cobertura.coveragedata.HasBeenInstrumented
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 13 more
earthmover
  • 4,395
  • 10
  • 43
  • 74
Tejas
  • 71
  • 1
  • 2
  • How are you including Cobertura in the classpath? Does net/sourceforge/cobertura/coveragedata/HasBeenInstrumented.class exist in the JAR file that you're including in the classpath? – Cel Skeggs Mar 29 '15 at 07:48

2 Answers2

2

You should add cobetura.jar to Bootstrap Classes with -Xbootclasspath. More info: https://docs.oracle.com/javase/8/docs/technotes/tools/findingclasses.html This needs to be done in order to load the cobetura classes, which are needed in order to load your app classes.

Anton Krosnev
  • 3,964
  • 1
  • 21
  • 37
-1

I have been able to get rid of this problem by running a late package goal, as it re-compiles and re-packages de code without Cobertura.

The goals I use are:

clean site package

ATorras
  • 4,073
  • 2
  • 32
  • 39