Jacoco agent conflicts with Websphere

896 views
Skip to first unread message

yves.l...@gmail.com

unread,
May 27, 2013, 9:49:55 AM5/27/13
to jac...@googlegroups.com
Hi,

I'm trying to enable a Jacoco agent for my Websphere 8.5 (JDK7) with following VM parameters:

-javaagent:d:/temp/jacocoagent.jar=excludes=*,output=tcpserver,address=*,port=2220,exclclassloader=*

Due to the fact that Websphere seems to instrument class files while deploying [1] I use offline instrumentation for all my EARs.

With the configuration above though I'm not able to start my Websphere anymore:

Caused by: java.lang.RuntimeException: Class java/util/UUID could not be instrumented.
at org.jacoco.agent.rt_1r70et.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:139)
at org.jacoco.agent.rt_1r70et.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:100)
at org.jacoco.agent.rt_1r70et.JacocoAgent.createRuntime(JacocoAgent.java:128)
at org.jacoco.agent.rt_1r70et.JacocoAgent.init(JacocoAgent.java:74)
at org.jacoco.agent.rt_1r70et.JacocoAgent.premain(JacocoAgent.java:165)
... 6 more
Caused by: java.lang.NoSuchFieldException: $jacocoAccess
at java.lang.Class.getFieldImpl(Native Method)
at java.lang.Class.getField(Class.java:775)
at org.jacoco.agent.rt_1r70et.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:137)
... 10 more

Additional notes:

* Jacoco agent is the first and only agent defined in the VM args
* I need a TCP server for the entire VM as the integration tests run remotely and concurrently for all my EARs. At the end of the tests the results are collected by my Jacoco client and dumped to the target folder of each application

Is there any fix for this? Different runtime [2]?

[1] https://groups.google.com/forum/#!msg/jacoco/-ZE9ZGwEMJQ/4nU1j0YKzz8J
[2] http://sourceforge.net/p/eclemma/discussion/614869/thread/fa17b9b2

Thanks
Yves

Marc Hoffmann

unread,
May 27, 2013, 11:15:10 AM5/27/13
to jac...@googlegroups.com
Hi,

what exact JRE version/vendor are you using?

Currently the runtime implementation is hardcoded in the Agent.

If you do offline instrumentation anyways there is no need to specify
the JaCoCo agent to the VM. You can simply package the jacocoagent.jar
with your application. See documentation for configuration in this
setup:

http://www.eclemma.org/jacoco/trunk/doc/offline.html

Cheers,
-marc

Yves Langisch

unread,
May 27, 2013, 11:38:40 AM5/27/13
to jac...@googlegroups.com
It's a IBM JDK 7.

I already package a jacocoagent.jar per EAR. But as mentioned in my second note I have multiple EARs doing integration tests at the same time and I need one overall TCPServer per VM. Specifying a system property for the TCPServer would lead to port conflicts.

Any options to make that work?

-
Yves
> --
> You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/s9k4RFjwsOw/unsubscribe?hl=en.
> To unsubscribe from this group and all its topics, send an email to jacoco+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Marc Hoffmann

unread,
May 27, 2013, 12:21:38 PM5/27/13
to jac...@googlegroups.com
Offline instrumented classes really need jacocoagent.jar on the
classpath. It probably will not work with the Java agent as it can't be
seen from the offline instrumented classes in the EARs.

There is a subtile difference between on-the-fly and offline mode:

- Classes instrumented on-the-fly "magically" connect to the agent
through Java JRE APIs, so in most cases you do not need to deal with
classloaders even in app servers.
- Offline instrumented classes get a direct dependency to APIs
provided in jacocoagent.jar. In this setup you need to make sure the
classes with jacocoagent.jar are directly seen by the instrumented
application classes.

In your case I would try the following:

- remove the individual jacocoagent.jar files from the EARs
- consult the documentation of your appserver where to place
jacocoagent.jar so all EARs can see it
- Configure the JaCoCo TCP server with system properties as described
in the JaCoCo documentation for offline mode

Cheers,
-marc

Yves Langisch

unread,
May 27, 2013, 12:30:42 PM5/27/13
to jac...@googlegroups.com
Marc, thanks for the confirmation.

That's the setup I had at the beginning but our Websphere admins do not allow any shared libraries. But since I now have the confirmation that this seems to be the only way to make it work I need to talk to them again ;)

-
Yves

Yves Langisch

unread,
May 29, 2013, 9:33:08 AM5/29/13
to jac...@googlegroups.com
Ok, one question regarding the shared library approach. How does the
bootstraping of the TCPServer work? I now have the jacocoagent visible
for the applications, system properties (with prefix jacoco-agent.) are
defined but the server does not listen on the specified port.

-
Yves

Yves Langisch

unread,
May 29, 2013, 10:06:34 AM5/29/13
to jac...@googlegroups.com
After deploying an offline instrumented EAR the TCPServer is now
listening. Thanks.

-
Yves

Marc R. Hoffmann

unread,
May 30, 2013, 12:27:56 AM5/30/13
to jac...@googlegroups.com
Great!

> How does the bootstraping of the TCPServer work?

If you simply put jacocoagent.jar on the classpath the JaCoCo runtime is
started when the first offline-instrumented class is loaded.

In case jacocoagent.jar is used as a Java agent the JaCoCo runtime is
started even before the main method of your application is called.

Best regards,
-marc

Neil Russell

unread,
Sep 30, 2013, 3:07:04 PM9/30/13
to jac...@googlegroups.com, yves.l...@gmail.com
Hi,

As I am new to both Jacoco and Websphere, I was hoping perhaps someone monitoring this list could clarify something about the below scenario?

I have maven goals to create instrumented and non-instrumented versions of the CLASS files (I understand that Sonar needs the non-instrumented files and we are using Sonar..)

However, I am not at all clear how to get the IBM websphere tools to "was-ify" the class files that were instrumented by the Jacoco offline stage.
I have been using the WAS6 maven plugin which appears to automate much of the invocation of the IBM WAS tools, but so far it seems to recompile
the source code rather than re-use the jacoco instrumented CLASS files?

TIA,

--N

Marc R. Hoffmann

unread,
Sep 30, 2013, 11:24:36 PM9/30/13
to jac...@googlegroups.com
Hi,

that's why we really recommend not to use offline instrumentation and
use the JaCoCo agent for on-the-fly instrumentation only. See documentation:

http://www.eclemma.org/jacoco/trunk/doc/agent.html
http://www.eclemma.org/jacoco/trunk/doc/prepare-agent-mojo.html

Best regards,
-marc
> https://groups.google.com/forum/#!msg/jacoco/-ZE9ZGwEMJQ/4nU1j0YKzz8J <https://groups.google.com/forum/#!msg/jacoco/-ZE9ZGwEMJQ/4nU1j0YKzz8J>
> [2]
> http://sourceforge.net/p/eclemma/discussion/614869/thread/fa17b9b2
> You received this message because you are subscribed to the Google
> Groups "JaCoCo and EclEmma Users" group.
> To unsubscribe from this group and stop receiving emails from it, send

ddr...@gmail.com

unread,
Dec 3, 2014, 4:21:52 AM12/3/14
to jac...@googlegroups.com, yves.l...@gmail.com
Open WebSphere debug mode, and then try again
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages