Jacoco - "Caused by: java.lang.ClassNotFoundException: org.jacoco.agent.rt.internal_6da5971.Offline"
<p>Trying to get coverage via jacoco using offline instrumentation (can't use on-the-fly instrumentation: due to powermock testcases) for a maven project.Added the jacocoagent.jar to classpath in surefire plugin as shown below. Renamed the "org.jacoco.agent-0.7.7.201606060606-runtime.jar" (from local maven repository) to "jacocoagent.jar" and kept that in the same folder where this pom.xml is residing.I'm hitting the below exception even after adding it to classpath. </p>

<p><strong>snippet of pom.xml (surefire - plugin configuration)</strong></p>

<pre><code>       &lt;plugin&gt;
             &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
             &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
             &lt;configuration&gt;
                     &lt;forkmode&gt;once&lt;/forkmode&gt;
                    &lt;additionalClasspathElements&gt;
            &lt;additionalClasspathElement&gt;jacocoagent.jar&lt;/additionalClasspathElement&gt;
                                        &lt;/additionalClasspathElements&gt;
              &lt;/configuration&gt;
     &lt;/plugin&gt;
</code></pre>

<p><strong>Exception seen on console:</strong></p>

<pre><code>#############
Number of foreign imports: 1
import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

-----------------------------------------------------

        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:166)
        ... 21 more
Caused by: java.lang.NoClassDefFoundError: org/jacoco/agent/rt/internal_6da5971/Offline
        at com.cisco.ise.ups.modelframework.hibernate.OracleNamingStrategy.$jacocoInit(OracleNamingStrategy.java)
        at com.cisco.ise.ups.modelframework.hibernate.OracleNamingStrategy.&lt;clinit&gt;(OracleNamingStrategy.java)
        at sun.misc.Unsafe.ensureClassInitialized(Native Method)
        at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
        at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:142)
        at java.lang.reflect.Field.acquireFieldAccessor(Field.java:1082)
        at java.lang.reflect.Field.getFieldAccessor(Field.java:1063)
        at java.lang.reflect.Field.get(Field.java:387)
        at com.cisco.ise.ups.build.WorkflowRunnerMojo.namingStrategyInstance(WorkflowRunnerMojo.java:335)
        at com.cisco.ise.ups.build.WorkflowRunnerMojo.setupWorkflowEnvironment(WorkflowRunnerMojo.java:514)
        at com.cisco.ise.ups.build.WorkflowRunnerMojo.execute(WorkflowRunnerMojo.java:816)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        ... 21 more
Caused by: java.lang.ClassNotFoundException: org.jacoco.agent.rt.internal_6da5971.Offline
        at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
        ... 33 more
[ERROR]
###############
</code></pre>

<p><strong>Steps followed:</strong></p>

<ol>
<li>"mvn compile" .</li>
<li>"mvn org.jacoco:jacoco-maven-plugin:instrument" </li>
<li>"mvn test" - Exception raised at this step.</li>
</ol>

<p>Please let me know of how to get rid of this exception ? Was that the right place to add classpath?? (in surefire plugin) OR should it be specified some where??</p>

<p>Thank you.</p>