Query regarding Offline instrumentation while running application through jar

23 views
Skip to first unread message

aksa...@gmail.com

unread,
Nov 21, 2018, 11:55:00 AM11/21/18
to JaCoCo and EclEmma Users
Hello Jacoco Team,

I was trying out several configurations for code coverage using Jacoco. I ran into one query. Please help to resolve it.

I have a Java Application which is executed using "java -jar service-app.jar" command. I tried to use offline instrumentation on this. I took the class file and used below command to do offline instrumentation
"java -jar jacococli.jar instrument service/target/classes --dest /instrumented"

Then I am starting the application using below command :
java -Djacoco-agent.output=tcpserver -Djacoco-agent.address=localhost -Djacoco-agent.port=6300 -Djacoco-agent.append=false -Djacoco-agent.jmx=true -cp .:instrumented:jacocoagent.jar -jar service-app.jar

but when I am trying to dump the coverage it show error :

[INFO] Connecting to localhost/127.0.0.1:6300.

This does not happen with java application that I start using Class Name(java Hellomain) instead of "java -jar" command.

Can you help regarding this.
Is there any configuration I am missing ?

Thanks
Amit

Marc Hoffmann

unread,
Nov 21, 2018, 12:59:17 PM11/21/18
to jac...@googlegroups.com

"When you use the -jar option, the specified JAR file is the source of all user classes, and other class path settings are ignored."

So if you really want to use offline instrumentation (why?) you need to instrument the jar file.

As always we recommend using the JaCoCo agent as a Java agent without the hassles of offline instrumentation.

Regards,
-marc


--
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 an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/83bff381-865e-48f9-b478-9fa7c80c50a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages