Unable to read execution data file

2,649 views
Skip to first unread message

nvk....@gmail.com

unread,
Aug 15, 2017, 5:08:40 PM8/15/17
to JaCoCo and EclEmma Users
Hi,
We are observing the "Unable to read execution data file" error consistently when we run our builds on TeamCity agents that have the Linux operating system. We believe the generated jacoco exec file is getting corrupted.
Can you please help us in resolving this error?

Jacoco version is 0.7.7.201606060606
Java version is 1.8.0_131
Ant version is 1.9.5

Following is the stacktrace of the error.
[jacoco:report] Loading execution data file /local/home/tcagent/TeamCityAgent/work/7cf8c5b5cc582291/build/tmp/pdk/jacoco/coverage/jacoco.exec
[12:22:35][jacoco:report] Unable to read execution data file /local/home/tcagent/TeamCityAgent/work/7cf8c5b5cc582291/build/tmp/pdk/jacoco/coverage/jacoco.exec
[12:22:35]
[antcall] The following error occurred while executing this line:
/local/home/tcagent/TeamCityAgent/work/7cf8c5b5cc582291/build/utils/buildinclude/build-quality.xml:1079: Unable to read execution data file /local/home/tcagent/TeamCityAgent/work/7cf8c5b5cc582291/build/tmp/pdk/jacoco/coverage/jacoco.exec

[12:22:35][Step 2/2] Process exited with code 1
[12:22:35][Step 2/2] Ant output
[12:22:35][Ant output] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:441)
[12:22:35][Ant output] at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
[12:22:35][Ant output] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
[12:22:35][Ant output] at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
[12:22:35][Ant output] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[12:22:35][Ant output] at java.lang.reflect.Method.invoke(Method.java:498)
[12:22:35][Ant output] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[12:22:35][Ant output] at org.apache.tools.ant.Task.perform(Task.java:348)
[12:22:35][Ant output] at org.apache.tools.ant.Target.execute(Target.java:435)
[12:22:35][Ant output] at org.apache.tools.ant.Target.performTasks(Target.java:456)
[12:22:35][Ant output] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
[12:22:35][Ant output] at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
[12:22:35][Ant output] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[12:22:35][Ant output] at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
[12:22:35][Ant output] at org.apache.tools.ant.Main.runBuild(Main.java:853)
[12:22:35][Ant output] at org.apache.tools.ant.Main.startAnt(Main.java:235)
[12:22:35][Ant output] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
[12:22:35][Ant output] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
[12:22:35][Ant output] Caused by: java.io.EOFException
[12:22:35][Ant output] at java.io.DataInputStream.readUnsignedShort(DataInputStream.java:340)
[12:22:35][Ant output] at java.io.DataInputStream.readUTF(DataInputStream.java:589)
[12:22:35][Ant output] at java.io.DataInputStream.readUTF(DataInputStream.java:564)
[12:22:35][Ant output] at org.jacoco.core.data.ExecutionDataReader.readExecutionData(ExecutionDataReader.java:148)
[12:22:35][Ant output] at org.jacoco.core.data.ExecutionDataReader.readBlock(ExecutionDataReader.java:115)
[12:22:35][Ant output] at org.jacoco.core.data.ExecutionDataReader.read(ExecutionDataReader.java:92)
[12:22:35][Ant output] at org.jacoco.core.tools.ExecFileLoader.load(ExecFileLoader.java:59)
[12:22:35][Ant output] at org.jacoco.ant.ReportTask.loadExecutionData(ReportTask.java:514)
[12:22:35][Ant output] ... 121 more
[12:22:35][Ant output]

Following is the configuration for jacoco
<target name="jacoco"
depends="jacoco-help, jacoco-setup"
unless="help"
description="Turns on JaCoCo instrumentation/reporting">
<property name="jacoco.enabled" value="true" />
<property name="test.coverage.reporttarget" value="jacoco-generate-report" />
<path id="classpath-jacoco-runtime">
<fileset dir="${lib.dir}">
<include name="**/build/*jacoco*.jar" />
<include name="**/build/asm*.jar" />
</fileset>
</path>
<pathconvert property="test.coverage.runtimejars" refid="classpath-jacoco-runtime" />
</target>

<target name="jacoco-setup"
depends="java-setup"
unless="jacoco-setup.completed"
xmlns:jacoco="antlib:org.jacoco.ant">
<property name="jacoco.tmp.dir" value="${build.tmp.dir}/jacoco" />
<property name="jacoco.coverage.dir" value="${jacoco.tmp.dir}/coverage" />
<mkdir dir="${jacoco.coverage.dir}" />
<property name="jacoco.reports.dir" value="${build.report.dir}/jacoco" />
<mkdir dir="${jacoco.reports.dir}" />
<property name="jacoco.result.file" value="${jacoco.coverage.dir}/jacoco.exec" />
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath>
<path refid="classpath-build"/>
</classpath>
</taskdef>
<jacoco:agent property="test.coverage.jvmargs"
destfile="${jacoco.result.file}"
append="true"
enabled="true"
output="file"/>
<property name="jacoco-setup.completed" value="true"/>
</target>

<target name="jacoco-generate-report"
depends="jacoco-setup"
if="jacoco.enabled"
xmlns:jacoco="antlib:org.jacoco.ant">
<jacoco:report>
<executiondata>
<file file="${jacoco.result.file}"/>
</executiondata>
<structure name="JaCoCo Report">
<classfiles>
<fileset dir="${java.main.classdir}"/>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${java.main.src}" />
</sourcefiles>
</structure>
<html destdir="${jacoco.reports.dir}" />
</jacoco:report>
<antcall target="report-summary">
<param name="summary.section" value="quality"/>
<param name="summary.entry" value="jacoco"/>
<param name="summary.entry.url" value="jacoco/index.html"/>
<param name="summary.entry.link" value="JaCoCo"/>
<param name="summary.entry.text" value="JaCoCo code coverage reports."/>
</antcall>
</target>

suhas nvk

unread,
Aug 15, 2017, 5:23:42 PM8/15/17
to JaCoCo and EclEmma Users
Please find the jacoco.exec file attached with this post.
jacoco.exec

Marc Hoffmann

unread,
Aug 16, 2017, 4:47:07 AM8/16/17
to jac...@googlegroups.com

Hi,

the exec file you provided is truncated. This probably means that the JVM running the test does not properly shut down.

Note that there is a known issue with Java 8. When the main thread is in the interrupted state the JVM shutdown hooks are not properly executed, see: https://bugs.openjdk.java.net/browse/JDK-8154017

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/73c3f540-667a-412b-894c-5dc901228541%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

 

jacoco.exec

suhas nvk

unread,
Aug 16, 2017, 2:01:08 PM8/16/17
to JaCoCo and EclEmma Users
Thank you Marc for the prompt reply. I appreciate your inputs. We will continue looking to see if there is a workaround by passing the JVM flags until Java 9 gets released.

Evgeny Mandrikov

unread,
Aug 16, 2017, 5:04:20 PM8/16/17
to JaCoCo and EclEmma Users
Hi,

Are you sure that you are affected exactly by mentioned bug (JDK-8154017)?
Maybe you are just not gracefully terminating JVM?
In a first case there is no such thing as "JVM flags" for workaround, the only solution is to change code to not leave main thread in interrupted state. 
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+unsubscribe@googlegroups.com.

danielj...@gmail.com

unread,
Aug 23, 2017, 4:12:12 PM8/23/17
to JaCoCo and EclEmma Users
On Tuesday, August 15, 2017 at 4:08:40 PM UTC-5, suhas nvk wrote:

I'm working on the same project; is there anyway to prevent the report task from running until the test output is complete?

Marc R. Hoffmann

unread,
Aug 24, 2017, 10:16:18 AM8/24/17
to jac...@googlegroups.com
Hi,

all JaCoCo tools will always throw an exception in truncated exec files.
The reports will be incomplete anyways.

If you're ok with an incomplete report I created a code snippet for you
which can heal the exec file for you:
https://gist.github.com/marchof/19aebb567ca4598c77b391460da39376

But please be warned: All classes that have been truncated will show as
uncovered in the coverage report. I would rather recommend to fix the
root cause.

Regards,
-marc

danielj...@gmail.com

unread,
Aug 24, 2017, 3:45:56 PM8/24/17
to JaCoCo and EclEmma Users

I would rather fix the incomplete report; any suggestions on how to stop the JVM from exiting prematurely while writing it?

Marc R. Hoffmann

unread,
Aug 25, 2017, 12:44:19 AM8/25/17
to jac...@googlegroups.com
As said before the only situation we know when this happens is when the
main method of a Java program exits with the interrupted thread status.
Have you checked this?

supar...@gmail.com

unread,
Nov 15, 2017, 6:44:21 AM11/15/17
to JaCoCo and EclEmma Users
Hi,

Probably your execution file is not generated the right way.

Feel free to check out our solution here:

http://www.qalearningguide.com/2017/10/code-coverage-for-android-using-jacoco.html

Hope this helps you as well.

Thanks,
Suparna

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