title: JaCoCo Offline Instrumentaion and Integration Test Coverage Reports
body: <p>I have been trying to implement JaCoCo offline code coverage in a JBoss server using an instrumented EAR for deployment and the jacococagent.jar in order to track code coverage of external integration testing running against said JBoss.</p>
  
  <p>I have been following guides such as these:</p>
  
  <p><a href="http://www.eclemma.org/jacoco/trunk/doc/offline.html" rel="nofollow noreferrer">http://www.eclemma.org/jacoco/trunk/doc/offline.html</a></p>
  
  <p><a href="http://automationrhapsody.com/code-coverage-with-jacoco-offline-instrumentation-with-maven/" rel="nofollow noreferrer">http://automationrhapsody.com/code-coverage-with-jacoco-offline-instrumentation-with-maven/</a> </p>
  
  <p>I feel I am pretty close as everything SEEMS to be working, however, when I load the coverage report up in eclipse's EclEmma plugin, it reports as 0 coverage for everything (which I know is wrong).</p>
  
  <p>Here's my setup:</p>
  
  <p>Here's the maven plugin configuration:</p>
  
  <pre><code>                &lt;plugin&gt;
                  &lt;groupId&gt;org.jacoco&lt;/groupId&gt;
                  &lt;artifactId&gt;jacoco-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;${jacoco.version}&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;!-- &lt;destFile&gt;${sonar.jacoco.reportPath}&lt;/destFile&gt; --&gt;
                      &lt;append&gt;true&lt;/append&gt;
  
                      &lt;excludes&gt;
                          &lt;exclude&gt;**/dao/**/*Dao*&lt;/exclude&gt;
                          &lt;exclude&gt;**/dao/**/*DAO*&lt;/exclude&gt;
                          &lt;exclude&gt;**/dao/**/*Vo*&lt;/exclude&gt;
                          &lt;exclude&gt;**/dao/**/*VO*&lt;/exclude&gt;
                          &lt;exclude&gt;**/ui/**/*&lt;/exclude&gt;
                          &lt;exclude&gt;**/*Vo.*&lt;/exclude&gt;
                          &lt;exclude&gt;**/*VO.*&lt;/exclude&gt;
                          &lt;exclude&gt;**/test/**/*&lt;/exclude&gt;
                          &lt;exclude&gt;**/tester/**/*&lt;/exclude&gt;
                      &lt;/excludes&gt;
  
                  &lt;/configuration&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;pre-unit-test&lt;/id&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;prepare-agent&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;destFile&gt;${sonar.jacoco.reportPath}&lt;/destFile&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                      &lt;execution&gt;
                          &lt;id&gt;unit-test-report&lt;/id&gt;
                          &lt;phase&gt;test&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;report&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;dataFile&gt;${sonar.jacoco.reportPath}&lt;/dataFile&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                      &lt;execution&gt;
                          &lt;id&gt;jacoco-instrument&lt;/id&gt;
                          &lt;phase&gt;test&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;instrument&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;skip&gt;${jacoco.skip.instrument}&lt;/skip&gt;
                              &lt;!-- &lt;skip&gt;false&lt;/skip&gt; --&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
  </code></pre>
  
  <p>Here's my jacoco-agent.properties file:</p>
  
  <pre><code>destfile=/stage/live_integration_jacoco.exec
  output=file
  dumponexit=true
  append=true
  </code></pre>
  
  <p>I'm bundling the JaCoCo Agent JARs right inside the EAR as these dependencies (the second one is just what jacocoagent.jar is labelled as in our repository):</p>
  
  <pre><code>        &lt;dependency&gt;
              &lt;groupId&gt;org.jacoco&lt;/groupId&gt;
              &lt;artifactId&gt;org.jacoco.agent&lt;/artifactId&gt;
              &lt;version&gt;${jacoco.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.jacoco.build&lt;/groupId&gt;
              &lt;artifactId&gt;org.jacoco.jacocoagent&lt;/artifactId&gt;
              &lt;version&gt;${jacoco.version}&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>Here's my process:</p>
  
  <p>I run this on the project: <code>mvn clean install -U -Djacoco.skip.instrument=false</code></p>
  
  <p>And that generates my instrumented EAR artifact.  I have verified that the classes in there are indeed instrumented by JaCoCo by decompiling a few of them.</p>
  
  <p>I take that EAR that has instrumented code, the jacococagent.jar included in it, and the jacoco-agent.popreties file included as well and deploy that to JBoss.  JBoss starts just fine (it used to get ClassNotFound exception before I started bundling jacocoagent.jar in it directly).</p>
  
  <p>The "/stage/live_integration_jacoco.exec" file is created at this point with a size of '0'.</p>
  
  <p>I run some tests on and against the server, even some manual testing, then stop the application.</p>
  
  <p>The "/stage/live_integration_jacoco.exec" file now has data (30-60kb of data so far in my observations).</p>
  
  <p>I import that exec file into eclipse and it loads without any errors and shows the classes in the project, however it reports 0 coverage on everything.</p>
  
  <p>Well, I'm not sure what else to try at this point.</p>
  
  <p>Does anyone have some thoughts on how to get it correctly generating the coverage report in my situation?</p>
  
  <p>Thanks!</p>