Hi,

On Friday, July 5, 2019 at 2:43:12 PM UTC+2, [email protected] 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?
>

This has been answered many times - please use search. For example - 
https://groups.google.com/forum/#!msg/jacoco/Jdgz90jw3ZY/YUAvvA7KBwAJ , 
https://groups.google.com/forum/#!msg/jacoco/q3xjdkOH_0g/3UMLI_9NAgAJ , 
https://groups.google.com/d/msg/jacoco/DZNqIGaoPKQ/5EbhZTAaAwAJ , etc.

JaCoCo registers standard JVM Shutdown hook - see 
http://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#addShutdownHook(java.lang.Thread)
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".
 

> 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
>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jacoco/c97be9ad-f8fa-4c7c-8caf-7c3aa34e5dd9%40googlegroups.com.

Reply via email to