coveralls-maven-plugin icon indicating copy to clipboard operation
coveralls-maven-plugin copied to clipboard

ArrayIndexOutOfBoundsException: 291 with cobertura report from scoverage

Open arahuja opened this issue 9 years ago • 6 comments

I'm using scoverage:1.1.0 to generate a cobertura report and it is created in target/cobertura.xml

Using coveralls maven plugin:3.1.0

          <plugin>
            <groupId>org.eluder.coveralls</groupId>
              <artifactId>coveralls-maven-plugin</artifactId>
              <version>3.1.0</version>
              <configuration>
                <coberturaReports>
                 <param>${project.build.directory}/cobertura.xml</param>
                </coberturaReports>
              <sourceDirectories>
                <param>${basedir}</param>
              </sourceDirectories>
              </configuration>
          </plugin>

I get the following exception:

[ERROR] Failed to execute goal org.eluder.coveralls:coveralls-maven-plugin:3.1.0:report (default-cli) on project guacamole: Build error: 291 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.eluder.coveralls:coveralls-maven-plugin:3.1.0:report (default-cli) on project guacamole: Build error
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Build error
    at org.eluder.coveralls.maven.plugin.CoverallsReportMojo.execute(CoverallsReportMojo.java:236)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 19 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 291
    at org.eluder.coveralls.maven.plugin.domain.Source.addCoverage(Source.java:92)
    at org.eluder.coveralls.maven.plugin.parser.CoberturaParser.onEvent(CoberturaParser.java:68)
    at org.eluder.coveralls.maven.plugin.parser.AbstractXmlEventParser.parse(AbstractXmlEventParser.java:64)
    at org.eluder.coveralls.maven.plugin.CoverallsReportMojo.writeCoveralls(CoverallsReportMojo.java:348)
    at org.eluder.coveralls.maven.plugin.CoverallsReportMojo.execute(CoverallsReportMojo.java:225)
    ... 21 more

arahuja avatar Jun 15 '15 21:06 arahuja

My guess is that you have multi-module project containing duplicate package/class names. If this is the case, there is no current solution available because it's impossible to detect the correct submodule from aggregated Cobertura report. See issue #56 for more details.

If the earlier is not the case then I would need a bit more information about the issue. Are there any weird encodings or new line characters used in the code files?

trautonen avatar Jun 16 '15 19:06 trautonen

@trautonen Thanks for the reply - this is a single module project and I don't believe package names should overlap at all - but I can double check in case it accidently happened. There also should not be any weird encodings, or new line characters used.

Is possible to check which source file is causing the error or get more information on what can't be found?

arahuja avatar Jun 16 '15 20:06 arahuja

Ok. I created a new snapshot that improves the exception message for the out of bounds issue. Could you add Sonatype's snapshot repository to your project and test with the 3.2.0-SNAPSHOT version.

        <repository>
            <id>sonatype-nexus-snapshots</id>
            <name>Sonatype Nexus Snapshots</name>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>

With those above set run your build for example on local machine with mvn -U -DdryRun=true org.eluder.coveralls:coveralls-maven-plugin:report

trautonen avatar Jun 16 '15 21:06 trautonen

Thanks for the update - I had to add to it pluginRepositories actually.

Running that says

Build error: Line number 292 is greater than the source file src/main/scala/org/hammerlab/guacamole/LociSet.scala size

which is true, that file only has 286 lines.

There are many tests that list a line number higher than that in the cobertura file unfortunately - the tests that seem to have higher line number on an inner class, could that be causing issues? Must be an issue with scoverage than.

Thanks!

arahuja avatar Jun 16 '15 22:06 arahuja

Can you create test project (for scoverage) generating wrong line numbers?

gslowikowski avatar Aug 24 '16 09:08 gslowikowski

I think I have this working in the repo @arahuja and I are concerned about, so we can probably close this.

Either something was fixed here or in maven-coveralls-plugin in the last year, or we both were tricked by not diligently-enough running mvn clean between running other non-scoverage coverage-report-generation tools and attempting with scoverage (which definitely happened to me at least once yesterday before I ultimately got things working).

I described my full configs for Maven+Scala+Scoverage+Coveralls here: https://github.com/trautonen/coveralls-maven-plugin/issues/98#issuecomment-242131735.

Thanks for following up!

ryan-williams avatar Aug 24 '16 17:08 ryan-williams