JaCoCo SonarQube incompatible version 1007

SonarqubeJacoco

Sonarqube Problem Overview


I'm using SonarQube for code quality control and suddenly builds that would otherwise pass can't be analyzed and fails.

> [INFO] [00:00:03.630] Analysing /mySuperProject/target/jacoco.exec -> > java.io.IOException: Incompatible version 1007

When I invoke maven build with debug switch, this cause is revealed

Caused by: java.io.IOException: Incompatible version 1007.
at org.jacoco.core.data.ExecutionDataReader.readHeader(ExecutionDataReader.java:127)
at org.jacoco.core.data.ExecutionDataReader.readBlock(ExecutionDataReader.java:107)
at org.jacoco.core.data.ExecutionDataReader.read(ExecutionDataReader.java:87)
at org.sonar.plugins.jacoco.AbstractAnalyzer.readExecutionData(AbstractAnalyzer.java:134)
at org.sonar.plugins.jacoco.AbstractAnalyzer.analyse(AbstractAnalyzer.java:107)

While inspecting jacoco ExecutionDataReader, I found that exception is thrown from

if (version != ExecutionDataWriter.FORMAT_VERSION) {
	throw new IOException(format("Incompatible version %x.",Integer.valueOf(version)));
}

and from ExecutionDataWriter I've found out

/** File format version, will be incremented for each incompatible change. */
public static final char FORMAT_VERSION = 0x1007;

What is this incompatible change and why does it happen? Any ideas how to fix this challenge?

Sonarqube Solutions


Solution 1 - Sonarqube

As already mentioned, this is due to a break in JaCoCo maven plugin code. You can (temporarily) specify the version in your jenkins maven command like:

clean org.jacoco:jacoco-maven-plugin:<version>:prepare-agent install

e.g.

clean org.jacoco:jacoco-maven-plugin:0.7.4.201502262128:prepare-agent install

This was the workaround that helped us. But like most people, I'm still waiting for the fix to come.

Solution 2 - Sonarqube

What I did was to specify the jacoco version in my maven project.

<jacoco-maven-plugin.version>0.7.4.201502262128</jacoco-maven-plugin.version>

    <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>${jacoco-maven-plugin.version}</version>
    </plugin>

That fix my issue!

Solution 3 - Sonarqube

Most likely that's caused by latest jacoco-maven-plugin update. Everything was working on 0.7.4.201502262128 but today we switched to 0.7.5.201505241946 which resulted in this error.

Solution 4 - Sonarqube

Run:

mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install
mvn org.jacoco:jacoco-maven-plugin:prepare-agent clean install -Pcoverage-per-test
mvn sonar:sonar

This will re-generate .exec files created by older versions of jacoco.

Solution 5 - Sonarqube

Try to update the Java plugin in SonarQube Update Center, this works for me. I updated the Java plugin from version 2.4 to latest 3.13.1.

SonarQube Update Center -> Plugin Updates -> Java

Solution 6 - Sonarqube

As kdowbecki mentionned it, this error is most likely due to an update of jacoco-maven-plugin.

Your SonarQube is most likely now using the new version of Jacoco Maven Plugin (probably the new 0.7.5.201505241946) but is actually trying to read an old version of a jacoco.exec (in your case it might be reading a jacoco.exec generated by jacoco maven plugin version 0.7.4.201502262128) which results in an incompatibility thrown by JaCoCo.

To fix this problem, you should make sure all your SonarQube/Jenkins jobs generate a JaCoCo report each time and do not rely on an older version of jacoco.exec that might have been generated by a previous job.

Solution 7 - Sonarqube

For me this, when doing a mvn install

Error while creating report: Cannot read execution data version 0x1006. This version of JaCoCo uses execution data version 0x1007

meant I had done an archetype generate but the archetype accidentally included the target directory with old jacoco files in it (or it had been checked into git on accident). Doing a mvn clean first (and checking that in) cleared up the issue. Guess jacoco is reluctant to overwrite the jacoco.exec file with a new one when there are no unit tests to run or something like that, so the old file gets preserved and attempted to used for the jacoco report. FWIW...

In general it means a version mismatch of generator vs. reporter.

Solution 8 - Sonarqube

I changed pom.xml like

groupId=org.jacoco
artifactId=jacoco-maven-plugin
version=0.8.4-SNAPSHOT

it worked for me

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPadvinderView Question on Stackoverflow
Solution 1 - SonarqubedeketimView Answer on Stackoverflow
Solution 2 - SonarqubeRémi RoyView Answer on Stackoverflow
Solution 3 - SonarqubeKarol DowbeckiView Answer on Stackoverflow
Solution 4 - SonarqubeBabken VardanyanView Answer on Stackoverflow
Solution 5 - SonarqubedereckView Answer on Stackoverflow
Solution 6 - SonarqubePom12View Answer on Stackoverflow
Solution 7 - SonarquberogerdpackView Answer on Stackoverflow
Solution 8 - SonarqubeRajitha BhanukaView Answer on Stackoverflow