java.lang.ClassNotFoundException: org.jacoco.agent.rt.internal_14f7ee5.Offline

8,037 views
Skip to first unread message

sharm...@gmail.com

unread,
Oct 26, 2016, 6:49:45 AM10/26/16
to JaCoCo and EclEmma Users
I have a maven project .I added the following to the pom.xml :
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.6.201602180812</version>
<executions>
<execution>
<id>jacoco-instrument</id>
<phase>test</phase>
<goals>
<goal>instrument</goal>
</goals>
</execution>
</executions>
</plugin>


when I do mvn clean install , I get

java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: org/jacoco/agent/rt/internal_14f7ee5/Offline
at org.apache.atlas.fs.model.FSDataModelGenerator.$jacocoInit(FSDataModelGenerator.java)
at org.apache.atlas.fs.model.FSDataModelGenerator.main(FSDataModelGenerator.java)
... 6 more
Caused by: java.lang.ClassNotFoundException: org.jacoco.agent.rt.internal_14f7ee5.Offline
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 8 more

How to resolve ?

Evgeny Mandrikov

unread,
Oct 26, 2016, 7:02:16 AM10/26/16
to JaCoCo and EclEmma Users, sharm...@gmail.com
Quoting FAQ entry "Why do I get an error "ClassNotFoundException: org.jacoco.agent[...]Offline"?" at http://www.eclemma.org/jacoco/trunk/doc/faq.html :

If you use offline instrumentation the instrumented classes get a direct dependency on the JaCoCo runtime. Therefore jacocoagent.jar of the same JaCoCo version must be on the classpath and accessible from by the instrumented classes.

In other words - you probably forgot to add a dependency.
Also you can check our example of offline instrumentation - http://www.eclemma.org/jacoco/trunk/doc/examples/build/pom-offline.xml

sharm...@gmail.com

unread,
Oct 26, 2016, 7:09:22 AM10/26/16
to JaCoCo and EclEmma Users, sharm...@gmail.com
Hi Evgeny,

Thanks for the quick response.

I am not running any tests yet. My main project and test code are in different places. I am trying to instrument the classes in main project by adding the jacoco plugin. When I do mvn install , I get the error.

I added the dependency

<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<version>0.7.6.201602180812</version>
</dependency>
(version matches the plugin version)

Still getting the error

Evgeny Mandrikov

unread,
Oct 26, 2016, 7:29:35 AM10/26/16
to JaCoCo and EclEmma Users, sharm...@gmail.com
You are missing line "<classifier>runtime</classifier>" in specification of dependency.
Once again - please carefully study mentioned example. And documentation. Thank you for your understanding.

sharm...@gmail.com

unread,
Oct 26, 2016, 7:32:20 AM10/26/16
to JaCoCo and EclEmma Users, sharm...@gmail.com
Hi,
Ran with and without classifier and scope . Facing the same issue.
Thanks for your response.

Evgeny Mandrikov

unread,
Oct 26, 2016, 7:35:00 AM10/26/16
to JaCoCo and EclEmma Users, sharm...@gmail.com
Sorry, but nothing to add to my previous messages. Unless if you'll make your project/example public, so that we can try it.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages