jacoco merge error - Unable to read execution data file

2,185 views
Skip to first unread message

rama.p...@jda.com

unread,
Sep 7, 2016, 7:58:28 AM9/7/16
to JaCoCo and EclEmma Users
Can we copy jacoco.exec ( execution data file) generated on linux to Windows and use it as input for merge ANT target? We are getting cannot read file(execution data file copied from linux) error while merge. Is there any way to fix this? More details below...

We want to merge execution data files generated on different envs (one generated on Linux for selenium and other generated on Windows for jUnits) to get a combined coverage report. We are using ANT, "jacoco:merge" is being run on Windows. We have copied jacoco.exec from Linux to Windows and trying to merge the files.

Marc R. Hoffmann

unread,
Sep 7, 2016, 2:26:10 PM9/7/16
to jac...@googlegroups.com
Hi,

exec files are platform independent. Note however, that they might be
incompatible between different JaCoCo releases, see
https://github.com/jacoco/jacoco/wiki/ExecFileVersions.

It might be helpful if you provide the full errer message ans stack trace.

Regards,
-marc

rama.p...@jda.com

unread,
Sep 8, 2016, 6:33:59 AM9/8/16
to JaCoCo and EclEmma Users, rama.p...@jda.com
On Wednesday, September 7, 2016 at 5:28:28 PM UTC+5:30, rama.p...@jda.com wrote:
> Can we copy jacoco.exec ( execution data file) generated on linux to Windows and use it as input for merge ANT target? We are getting cannot read file(execution data file copied from linux) error while merge. Is there any way to fix this? More details below...
>
> We want to merge execution data files generated on different envs (one generated on Linux for selenium and other generated on Windows for jUnits) to get a combined coverage report. We are using ANT, "jacoco:merge" is being run on Windows. We have copied jacoco.exec from Linux to Windows and trying to merge the files.

Hi Marc,

Here is the complete stacktrace

[jacoco:merge] Loading execution data file E:\test\jacoco.exec

BUILD FAILED
E:\test\build.xml:571: Unable to read E:\test\jacoco.exec
at org.jacoco.ant.MergeTask.load(MergeTask.java:87)
at org.jacoco.ant.MergeTask.execute(MergeTask.java:67)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe
cutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.Main.runBuild(Main.java:854)
at org.apache.tools.ant.Main.startAnt(Main.java:236)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
Caused by: java.io.IOException: Unknown block type a.
at org.jacoco.core.data.ExecutionDataReader.readBlock(ExecutionDataReade
r.java:116)
at org.jacoco.core.data.ExecutionDataReader.read(ExecutionDataReader.jav
a:87)
at org.jacoco.core.tools.ExecFileLoader.load(ExecFileLoader.java:59)
at org.jacoco.ant.MergeTask.load(MergeTask.java:85)
... 17 more

Below is my ANT target. In this mod1 jacoco.exec file was copied from a linux box and mod2 jacoco.exec files were generated on same windows m/c where merge target is run.

<target name="merge-all-modules">
<jacoco:merge destfile="${mytest.dir}/target/merged.exec">
<fileset dir="${mytest.dir}/target/mod2" includes="jacoco.exec" />
<fileset dir="${mytest.dir}/target/mod1" includes="*.exec" />
</jacoco:merge>
<jacoco:report>
<executiondata>
<file file="${mytest.dir}/target/merged.exec" />
</executiondata>
<structure name="MyTestPrj">
<group name="module1">
<classfiles>
<fileset dir="${mytest.dir}/output/classes"/>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${mytest.dir}/source"/>
</sourcefiles>
</group>
<group name="module2">
<classfiles>
<fileset dir="${mytest.dir}/output/mod1classes"/>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${mytest.dir}/mod1src"/>
</sourcefiles>
</group>
</structure>
<html destdir="${mytest.dir}/target/output" />
</jacoco:report>
</target>

Marc R. Hoffmann

unread,
Sep 8, 2016, 11:53:46 PM9/8/16
to jac...@googlegroups.com
Hi,

thanks for the stack trace! The trace indicates that
"E:\test\jacoco.exec" is not a valid execution data file or it has been
corrupted somehow.

If you can provide this file I can have a look what the issue is. You
can also inspect the file yourself using our code example here:

http://www.eclemma.org/jacoco/trunk/doc/examples/java/ExecDump.java

Regards,
-marc

Rama

unread,
Sep 9, 2016, 12:41:47 AM9/9/16
to JaCoCo and EclEmma Users
I tried to verify using example your provided and the problem is "Unknown block type a". What does this mean?


Exception in thread "main" java.io.IOException: Unknown block type a.


at org.jacoco.core.data.ExecutionDataReader.readBlock(ExecutionDataReader.java:116)
at org.jacoco.core.data.ExecutionDataReader.read(ExecutionDataReader.java:87)

at com.jda.nextgen.ua.widthndepth.JacocoDiag.dump(JacocoDiag.java:64)
at com.jda.nextgen.ua.widthndepth.JacocoDiag.execute(JacocoDiag.java:38)
at com.jda.nextgen.ua.widthndepth.JacocoDiag.main(JacocoDiag.java:89)

rama.p...@jda.com

unread,
Sep 9, 2016, 12:43:40 AM9/9/16
to JaCoCo and EclEmma Users, rama.p...@jda.com
On Friday, September 9, 2016 at 10:11:47 AM UTC+5:30, Rama wrote:
> I tried to verify using example your provided and the problem is "Unknown block type a". What does this mean?
>
>
> Exception in thread "main" java.io.IOException: Unknown block type a.
> at org.jacoco.core.data.ExecutionDataReader.readBlock(ExecutionDataReader.java:116)
> at org.jacoco.core.data.ExecutionDataReader.read(ExecutionDataReader.java:87)
>
>
>
>

Marc R. Hoffmann

unread,
Sep 9, 2016, 2:38:57 AM9/9/16
to jac...@googlegroups.com
If this is the only output then the file is not an execution data file
at all.

How exactly do you create the file?

rama.p...@jda.com

unread,
Sep 9, 2016, 7:19:01 AM9/9/16
to JaCoCo and EclEmma Users
I tried regenerating this file and now it looks like working. Thanks for all your help

I created this file passing -javaagent:/usr1/vendor/jacoco/lib/jacocoagent.jar=destfile=/usr1/jacococoverage/jacoco.exec,includes=com.myapp.* as javaopts to catalina.bat and this file was written when the server is stopped.

Evgeny Mandrikov

unread,
Sep 24, 2016, 4:09:09 PM9/24/16
to JaCoCo and EclEmma Users
Just my 2 cents as an additional note and word of warning: Marc, you probably forgot - while exec files are OS independent, they are heavily coupled to bytecode, i.e. copy is safe if bytecode doesn't change between tests and report generation. And if my memory is correct, then we had an examples, where simple recompilation without changes in environment (same Javac and so on) produces different bytecode.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages