Unable to read execution data file - reports\jacoco.exec

7,693 views
Skip to first unread message

gosav...@gmail.com

unread,
Oct 1, 2015, 10:57:36 AM10/1/15
to JaCoCo and EclEmma Users
Hi All,
I am running code coverage using Jacoco, and getting error "Unable to read execution data file - reports\jacoco.exec"

OS - Windows7
JDK - 1.6 / (I tried with JDK 1.7 as well)
Jacoco - latest Jars

Below is the task definition

<jacoco:coverage destfile="reports/jacoco.exec" exclclassloader="javassist.Loader">
<junit printsummary="yes" haltonfailure="yes" fork="yes" showoutput="yes">
<formatter type="xml"/>
<classpath>
<pathelement location="${test.classes.dir}"/>
<pathelement location="${target.classes.dir}"/>
<pathelement location="C:\kedar\work\CodeCoverage\DF1073Base\target\classes"/>
<fileset dir="${slib.dir}">
<include name="**/*.jar" />
</fileset>
</classpath>

<batchtest fork="no" todir="reports">
<fileset dir="test">
<include name="**/*Test*.java"/>
</fileset>
</batchtest>
</junit>
</jacoco:coverage>

<jacoco:report>
<executiondata>
<file file="reports/jacoco.exec"/>
</executiondata>
<structure name="JaCoCo Ant Example">
<classfiles>
<fileset dir="${test.classes.dir}"/>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="src"/>
</sourcefiles>
</structure>
<html destdir="reports"/>
<csv destfile="reports/report.csv"/>
<xml destfile="reports/report.xml"/>
</jacoco:report>
</target>


If I keep "batchtest fork="no"" - Jacoco executes the Test cases successfully - But Does not generate jacoco.exec file. Can someone help to identify - Why is not generating the jacoco.exec file?

If I keep "batchtest fork="yes/true"" - Jacoco generates jacoco.exec file, but all the test cases fail saying "Class not found sun/reflect/GeneratorAccessorMethod".

Please let me know if more information is required.


Marc Hoffmann

unread,
Oct 2, 2015, 4:08:35 AM10/2/15
to jac...@googlegroups.com
Hi,

looks like we have several issues here. Let's start with the JUnit test
failure. Can you please provide

1) Exact version of JaCoCo you're using
2) Full JDK version (java -version)
3) Full stack trace of failure

Thanks,
-marc

gosav...@gmail.com

unread,
Oct 10, 2015, 10:17:53 PM10/10/15
to JaCoCo and EclEmma Users, gosav...@gmail.com

Hi Marc,
Thanks for response, sorry for late reply.

We have
1. Jacoco 0.7.5
2. JDK 1.6.29 (Also Tried with JDK 1.7)
3. Stack Trace when 'fork='yes' in batchtest target

Buildfile: C:\batch\build.xml
test:
[delete] Deleting directory C:\batch\target\classes\test
[mkdir] Created dir: C:\batch\target\classes\test
[javac] Compiling 2 source files to C:\batch\target\classes\test
[javac] WARNING
[javac] The -source switch defaults to 1.7 in JDK 1.7.
[javac] If you specify -target 1.6 you now must also specify -source 1.6.
[javac] Ant will implicitly add -source 1.6 for you. Please change your build file.
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.6
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] 1 warning
[delete] Deleting directory C:\batch\reports
[mkdir] Created dir: C:\batch\reports
[jacoco:coverage] Enhancing junit with coverage
[junit] Running com.citi.doddfrank.batch.DFBICSortMapDataUploadTest
[junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.847 sec
[junit] log4j:WARN No appenders could be found for logger (org.springframework.test.context.junit4.SpringJUnit4ClassRunner).
[junit] log4j:WARN Please initialize the log4j system properly.
[junit] log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
[junit] Running batch.ABCTest
[junit] Exception in thread "main" java.lang.NoClassDefFoundError: sun/reflect/GeneratedMethodAccessor4
[junit] at sun.reflect.GeneratedMethodAccessor4.<init>(Unknown Source)
[junit] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[junit] at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
[junit] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
[junit] at java.lang.reflect.Constructor.newInstance(Unknown Source)
[junit] at java.lang.Class.newInstance(Unknown Source)
[junit] at sun.reflect.MethodAccessorGenerator$1.run(Unknown Source)
[junit] at sun.reflect.MethodAccessorGenerator$1.run(Unknown Source)
[junit] at java.security.AccessController.doPrivileged(Native Method)
[junit] at sun.reflect.MethodAccessorGenerator.generate(Unknown Source)
[junit] at sun.reflect.MethodAccessorGenerator.generateMethod(Unknown Source)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[junit] at java.lang.reflect.Method.invoke(Unknown Source)
[junit] at org.apache.commons.logging.LogFactory.getContextClassLoader(LogFactory.java:442)
[junit] at org.apache.commons.logging.LogFactory$1.run(LogFactory.java:222)
[junit] at java.security.AccessController.doPrivileged(Native Method)
[junit] at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:218)
[junit] at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
[junit] at org.springframework.test.annotation.ProfileValueUtils.<clinit>(ProfileValueUtils.java:40)
[junit] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.getDescription(SpringJUnit4ClassRunner.java:152)
[junit] at org.junit.runner.Runner.testCount(Runner.java:41)
[junit] at junit.framework.JUnit4TestAdapter.countTestCases(JUnit4TestAdapter.java:34)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:519)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:1060)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:911)
[junit] Running batch.ABCTest
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec

BUILD FAILED
C:\work\CodeCoverage\abc\build.xml:274: Test batch.ABCTest failed (crashed)

Total time: 21 seconds

Marc R. Hoffmann

unread,
Oct 12, 2015, 2:02:31 AM10/12/15
to jac...@googlegroups.com
Ok, here is the problem: If you configure a custim exclclassloader
please make sure to also exclude sun.reflect.DelegatingClassLoader
(which is the default value), otherwise reflection will not work. so
your coverage tag should read:

exclclassloader="sun.reflect.DelegatingClassLoader:javassist.Loader"

See documentation: http://eclemma.org/jacoco/trunk/doc/agent.html

Regards,
-marc

gosav...@gmail.com

unread,
Oct 15, 2015, 7:54:52 AM10/15/15
to JaCoCo and EclEmma Users
Bingo!!!

You are spot on Marc. That was exactly the problem. Thanks for your help.

You deserve a Party from my end :)

Marc Hoffmann

unread,
Oct 19, 2015, 7:27:27 AM10/19/15
to jac...@googlegroups.com
You're welcome! Just let me know when and where the party takes place
;-)

Cheers,
-marc

ssdha...@gmail.com

unread,
Dec 4, 2015, 8:25:23 AM12/4/15
to JaCoCo and EclEmma Users
Hi Marc,
I have put so much effort in testing the application and now i am facing this error.
Please give me any other solution apart from this.
Thanks

Marc R. Hoffmann

unread,
Dec 7, 2015, 12:07:09 AM12/7/15
to jac...@googlegroups.com
What specific error do you get? Can you please provide some log entries
or stack traces?

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