JaCoCo report fails in Jenkins: java.lang.ArrayIndexOutOfBoundsException

Lydia Ralph picture Lydia Ralph · Feb 23, 2015 · Viewed 7.8k times · Source

I have been using JaCoCo locally with no problem.

When running a Jenkins job on a remote server, the job builds fine and generates JaCoCo coverage report (i.e. it appears in my workspace/report folder) but the build fails when attempting to publish the report on Jenkins.

I am using Jenkins 1.460 and JaCoCo 5.0.0.

I have configured Jenkins with:

  • Path to exec files: **/**.exec
  • Path to classes: **/dist/validation/WEB-INF/classes
  • Path to source: **/src (I have also tried **/Validation/src, and explicitly including **/**.class and excluding other file types)

Is this a configuration problem, or a compatibility error?

[EDIT: In case it helps anyone else, other forums say JaCoCo requires ASM 5.+ to manage Java 8 class analysis. I am already using ASM 5.0.1.]

BUILD SUCCESSFUL
Total time: 4 minutes 57 seconds
Archiving artifacts
Recording test results
[JaCoCo plugin] Collecting JaCoCo coverage data...
[JaCoCo plugin] **/**.exec;**/dist/validation/WEB-INF/classes;**/Validation/src; locations are configured
[JaCoCo plugin] Number of found exec files for pattern **/**.exec: 1
[JaCoCo plugin] Saving matched execfiles:  E:\Jenkins\jobs\Validation - Test Cases\workspace\Validation\jacoco.exec
[JaCoCo plugin] Saving matched class directories for class-pattern: **/dist/validation/WEB-INF/classes:  E:\Jenkins\jobs\Validation - Test Cases\workspace\Validation\dist\validation\WEB-INF\classes
[JaCoCo plugin] Saving matched source directories for source-pattern: **/Validation/src:  E:\Jenkins\jobs\Validation - Test Cases\workspace\Validation\src
[JaCoCo plugin] Loading inclusions files..
[JaCoCo plugin] inclusions: []
[JaCoCo plugin] exclusions: []
ERROR: Publisher hudson.plugins.jacoco.JacocoPublisher aborted due to exception
java.io.IOException: Error while analyzing class E:\Jenkins\jobs\Validation - Test Cases\builds\2015-02-23_15-59-44\jacoco\classes\org\gosh\validation\filters\ModifiedFileListFilter.class.
    at org.jacoco.core.analysis.Analyzer.analyzerError(Analyzer.java:150)
    at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:144)
    at org.jacoco.core.analysis.Analyzer.analyzeAll(Analyzer.java:175)
    at org.jacoco.core.analysis.Analyzer.analyzeAll(Analyzer.java:208)
    at hudson.plugins.jacoco.ExecutionFileLoader.analyzeStructure(ExecutionFileLoader.java:126)
    at hudson.plugins.jacoco.ExecutionFileLoader.loadBundleCoverage(ExecutionFileLoader.java:133)
    at hudson.plugins.jacoco.JacocoReportDir.parse(JacocoReportDir.java:102)
    at hudson.plugins.jacoco.JacocoBuildAction.loadRatios(JacocoBuildAction.java:291)
    at hudson.plugins.jacoco.JacocoBuildAction.load(JacocoBuildAction.java:273)
    at hudson.plugins.jacoco.JacocoPublisher.perform(JacocoPublisher.java:371)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
    at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:705)
    at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:680)
    at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:658)
    at hudson.model.Build$RunnerImpl.post2(Build.java:162)
    at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:627)
    at hudson.model.Run.run(Run.java:1446)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:238)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 7
    at org.jacoco.core.internal.analysis.MethodAnalyzer.addProbe(MethodAnalyzer.java:288)
    at org.jacoco.core.internal.analysis.MethodAnalyzer.visitInsnWithProbe(MethodAnalyzer.java:224)
    at org.jacoco.core.internal.flow.MethodProbesAdapter.visitInsn(MethodProbesAdapter.java:76)
    at org.objectweb.asm.tree.InsnNode.accept(InsnNode.java:80)
    at org.objectweb.asm.tree.InsnList.accept(InsnList.java:162)
    at org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:815)
    at org.jacoco.core.internal.flow.ClassProbesAdapter$1.visitEnd(ClassProbesAdapter.java:124)
    at org.objectweb.asm.ClassReader.b(Unknown Source)
    at org.objectweb.asm.ClassReader.accept(Unknown Source)
    at org.objectweb.asm.ClassReader.accept(Unknown Source)
    at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:107)
    at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:142)
    ... 18 more
Finished: FAILURE

[UPDATE - solution]

Using this answer I installed the recently released JaCoCo-0.7.4 (see eclemma.org/jacoco) on my local drive. This version contains the fix for issue 27088. I also had to delete and then reinstall the Jenkins JaCoCo plugin (I used the Jenkins Plugin Manager).

Answer

MyKey_ picture MyKey_ · Feb 24, 2015

There appears to be a compatibility problem between the JaCoCo version used during build and the version used by Jenkins in the post-build action.

The maven-jacoco-plugin version 0.7.3.201502191951 in combination with the Jenkins JaCoCo Plugin version 1.0.18 causes this problem. Version 0.7.2.201409121644 of the maven-jacoco-plugin appears to be compatible.

See also https://issues.jenkins-ci.org/browse/JENKINS-27088 and https://github.com/jenkinsci/jacoco-plugin/pull/51