title: cobertura problem with asm on the classpath
body: <p>I've got a project setup using maven, Spring 2.5.6, Hibernate 3.2.6 and recently added cobertura 1.9rc1 for code coverage analysis. </p>
  
  <p>The first issue I ran into were classpath related errors because of two different versions of the asm.jar on the classpath. This issue would only rise when running the JUnit tests and trying to load the spring application context. </p>
  
  <p>According to the FAQ on cobertura project homepage: </p>
  
  <blockquote>
    <p>Why is Cobertura causing me to have classpath conflicts with ASM?</p>
    
    <p>Cobertura uses ASM to modify your bytecode. There are a few other popular programs that use ASM; Groovy and Hibernate, to name two. You could have problems if Cobertura uses a different version of asm and you add both versions to your classpath.</p>
    
    <p>Cobertura only uses ASM when instrumenting. Cobertura does not need ASM in your classpath when running tests. If you're seeing classpath conflicts, just make sure the asm jar that comes with Cobertura is used only by Cobertura, and only when instrumenting.</p>
  </blockquote>
  
  <p>So in my project pom I configured the dependency as follows:</p>
  
  <pre><code>&lt;dependency&gt;
                  &lt;groupId&gt;net.sourceforge.cobertura&lt;/groupId&gt;
          &lt;artifactId&gt;cobertura&lt;/artifactId&gt;
          &lt;version&gt;1.9rc1&lt;/version&gt;
          &lt;exclusions&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;asm&lt;/groupId&gt;
                  &lt;artifactId&gt;asm&lt;/artifactId&gt;
              &lt;/exclusion&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;asm&lt;/groupId&gt;
                  &lt;artifactId&gt;asm-attrs&lt;/artifactId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Now I can run my unit tests from eclipse, my application also runs fine on the server.</p>
  
  <p>But, when I run mvn cobertura:cobertura on my project I get the following error:
  <strong>java.lang.NoClassDefFoundError: net/sourceforge/cobertura/coveragedata/TouchCollector</strong></p>
  
  <p>I assume this is because the wrong asm.jar is on the classpath. But how else can I solve this classpath conflict, as stated in the cobertura faq?</p>