problems on output=file and output=tcpclient

47 views
Skip to first unread message

lvhu...@gmail.com

unread,
Jul 5, 2019, 8:43:12 AM7/5/19
to JaCoCo and EclEmma Users
hi,

I was trying the javaagent way. The output=tcpserver approach worked well, but output=file and output=tcpclient didn't seem to work. For output=file, the file was created but was always empty. For output=tcpclient, I used 'netcat -l -p <port>' as the tcpserver but nothing was received.

I searched and found that, only when the JVM was terminated, will the execution result be written to the local file or sent to the remote tcp server. So I stopped my tomcat after the tests were executed. But still no content was written to the file or sent to the tcp server.

Anything wrong? Do we need to a particular method to terminate tomcat/JVM? What if I simply "kill -9" to kill tomcat?

Here's the JAVA_OPTS I added to catalina.sh for the two approaches, respectively:

JAVA_OPTS="-javaagent:/data/project/jacoco/lib/jacocoagent.jar=includes=*,output=file,destfile=/data/project/result/xyz,append=true,jmx=true"

JAVA_OPTS="-javaagent:/data/project/jacoco/lib/jacocoagent.jar=includes=*,output=tcpclient,address=127.0.0.1,port=9529"

Any tips would be highly appreciated!

Thanks.
--huafeng

Evgeny Mandrikov

unread,
Jul 5, 2019, 9:42:40 AM7/5/19
to JaCoCo and EclEmma Users
Hi,


On Friday, July 5, 2019 at 2:43:12 PM UTC+2, lvhu...@gmail.com wrote:
hi,

I was trying the javaagent way. The output=tcpserver approach worked well, but output=file and output=tcpclient didn't seem to work. For output=file, the file was created but was always empty. For output=tcpclient, I used 'netcat -l -p <port>' as the tcpserver but nothing was received.

I searched and found that, only when the JVM was terminated, will the execution result be written to the local file or sent to the remote tcp server. So I stopped my tomcat after the tests were executed. But still no content was written to the file or sent to the tcp server.

Anything wrong? Do we need to a particular method to terminate tomcat/JVM? What if I simply "kill -9" to kill tomcat?



For execution of shutdown hooks JVM must be terminated gracefully, i.e. not by "kill -9".

Last of the above threads even shows usage of "output=file" with Tomcat - https://groups.google.com/d/msg/jacoco/DZNqIGaoPKQ/ZvSL0xyyCQAJ
For the graceful stop of Tomcat please refer to its documentation, AFAIK "catalina.sh stop" performs graceful stop.

Dump to file can be requested prior to JVM shutdown via JXM using JaCoCo agent with option "jmx=true".
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages