Search code examples
javamavensonarqubesonarqube-5.0

SonarQube 5.1 analysis fail with StackOverflowError


I recently upgraded to the newest SonarQube 5.1, but now, my maven builds have begun failing and I'm unable to determine what file is causing the error. The maven project is a multi module project.

  • SonarQube version 5.1
  • maven goal executed with "mvn sonar:sonar" (version 2.6 is used and the correctly analyses some of the projects)

The maven build finishes with the following error:

[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project flex-parentpom: null: MojoExecutionException: StackOverflowError -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project flex-parentpom: null
    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
    at org.codehaus.mojo.sonar.bootstrap.ExceptionHandling.handle(ExceptionHandling.java:41)
    at org.codehaus.mojo.sonar.bootstrap.RunnerBootstraper.execute(RunnerBootstraper.java:139)
    at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:132)
    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.StackOverflowError
    at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBinaryExpression(BaseTreeVisitor.java:208)
    at org.sonar.java.model.expression.BinaryExpressionTreeImpl.accept(BinaryExpressionTreeImpl.java:85)
    at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:42)
    at org.sonar.java.resolve.SemanticModel$1.scan(SemanticModel.java:92)
    at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBinaryExpression(BaseTreeVisitor.java:208)
    at org.sonar.java.model.expression.BinaryExpressionTreeImpl.accept(BinaryExpressionTreeImpl.java:85)
    at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:42)
    at org.sonar.java.resolve.SemanticModel$1.scan(SemanticModel.java:92)
    at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBinaryExpression(BaseTreeVisitor.java:208)
    at org.sonar.java.model.expression.BinaryExpressionTreeImpl.accept(BinaryExpressionTreeImpl.java:85)
    at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:42)
    at org.sonar.java.resolve.SemanticModel$1.scan(SemanticModel.java:92)
    at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBinaryExpression(BaseTreeVisitor.java:208)
    at org.sonar.java.model.expression.BinaryExpressionTreeImpl.accept(BinaryExpressionTreeImpl.java:85)
    at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:42)
    at org.sonar.java.resolve.SemanticModel$1.scan(SemanticModel.java:92)

Any ideas for debugging the cause of the error? I've attempted with -debug flag.


Solution

  • Problem solved.

    I ended up setting up a local instance and running the maven plugin using a debugger, this allowed me to set a breakpoint at the exception. I turned out that we had a test case (file) which had a field defined by hundreds of Strings. This file has not been edited for a long time, so I guess the overall stack size has changed from 4.x to 5.x. The test was ugly and my solution in this case was therefore to refactor it. I guess another solution would be to increase the java stack size, but I've not tried it.