title: Jenkins Cobertura build - NoClassDefFoundError
body: <p>I have a test class <code>ProcessorTest</code> with the lines</p>
  
  <pre><code>JSONObject jsonObj = XML.toJSONObject(convert);
  DBOb = (DBObject) JSON.parse(jsonObj.toString());
  </code></pre>
  
  <p>The XML class is from <a href="http://www.json.org/java/index.html" rel="nofollow">json.org</a>. The class is used else where in the code without a problem.</p>
  
  <p>Everything runs fine on localhost (i.e., all Maven and JUnit tests execute).</p>
  
  <p>When I pushed to Jenkins I get this error:</p>
  
  <p><strong>Jenkins Error</strong></p>
  
  <pre><code>Error Details
  net/sourceforge/cobertura/coveragedata/TouchCollector
  
  Stack Trace
  java.lang.NoClassDefFoundError: net/sourceforge/cobertura/coveragedata/TouchCollector
      at org.json.XML.__cobertura_init(XML.java)
      at org.json.XML.&lt;clinit&gt;(XML.java)
      at ProcessorTest.classSetup(ProcessorTest.java:81)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
      at org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.run(JUnit45AndHigherRunnerImpl.java:37)
      at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:62)
      at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
      at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
      at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
      at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
      at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
      at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
      at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
  Caused by: java.lang.ClassNotFoundException: net.sourceforge.cobertura.coveragedata.TouchCollector
      at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
      ... 26 more
  </code></pre>
  
  <p>I'm using Jenkins 1.553 and the Cobertura plugin 1.9.6.</p>
  
  <p>How do I fix this?</p>
  
  <p>The project structure is like this:</p>
  
  <pre><code>-- project1
       |
       | - core
       | - Tests (includes the tests that fail)
  
  
  -- org.json
       |
       | - XML.class
  </code></pre>
  
  <p>When pushed to Jenkins I assume the <code>org.json</code> project is unavailable for the tests.</p>