jacoco and tomcat, class dump created but jacoco.exec empty

2,221 views
Skip to first unread message

Glenn Caccia

unread,
Aug 24, 2015, 12:22:06 PM8/24/15
to JaCoCo and EclEmma Users
Hey all,

I'm trying to get code coverage for a tomcat app.  I've used jacoco before for tomcat apps and have been successful in getting reports.  My process is to attach the jacoco agent to the tomcat process, run my tests, shut down tomcat, and then generate a report using a maven project with the jacoco.exec and src files as the source material (see below for agent config).  With this latest tomcat app, however, after shutting down the tomcat app, jacoco.exec has a size of 0.  Despite this, it is creating class dump files, which would seem to suggest that it is recognizing the execution of code.  Does that make any sense?  Any ideas on what would cause jacoco.exec to be empty despite the creation of class dump files?  One thing that is different about this tomcat app compared to others is that it is a multi-module project.  Would that cause problems in this context?  If yes, any suggestions on how to work around the problem?

Thanks,

Glenn

-javaagent:${CATALINA_BASE}/webapps/tomcatAppName/WEB-INF/lib/jacocoagent.jar=output=file,destfile=${CATALINA_BASE}/logs/jacoco.exec,dumponexit=true,includes=com.mycompany.rss.mme.*,classdumpdir=${CATALINA_BASE}/logs/classes,append=false

Evgeny Mandrikov

unread,
Aug 24, 2015, 5:35:28 PM8/24/15
to JaCoCo and EclEmma Users
Hi,

To write dump file JaCoCo registers standard JVM ShutDown hook ( see http://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#addShutdownHook(java.lang.Thread) ), whose execution not guaranteed if JVM was not gracefully terminated. So probably the first thing to check - is how Tomcat terminated.

Marc R. Hoffmann

unread,
Aug 25, 2015, 12:54:35 AM8/25/15
to jac...@googlegroups.com
Hi Glenn,

files are written in the following sequence:

1) At startup a empty jacoco.exec file is writen to ensure that the specified location is writable
2) Classes are dumped whenever a class is loaded
3) Execution data is written out in the JVM's shutdown hook, which requires proper termination

This explains while files in 1) and 2) are writtem even if the JVM is not properly terminated.

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/597ca800-251f-4e87-899e-0f94798181e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Glenn Caccia

unread,
Aug 25, 2015, 6:55:00 PM8/25/15
to JaCoCo and EclEmma Users
Just to clarify, the issue (or confusion) is that the class dumps are getting created, but jacoco.exec remains empty.  I'm shutting tomcat down the same way we do for all our other services, so I don't think that is an issue.

Evgeny Mandrikov

unread,
Aug 31, 2015, 11:50:22 AM8/31/15
to JaCoCo and EclEmma Users
As Marc explained above - dump of classes and creation of "jacoco.exec" are two separate processes.
Could you provide minimalistic reproducer of your issue?
Also could be noted that creation of "jacoco.exec" can be triggered via JMX - see description of option "jmx" at http://www.eclemma.org/jacoco/trunk/doc/agent.html
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages