Rasheed G
Rasheed G

Reputation: 73

Can not execute Findbugs: java.lang.OutOfMemoryError: Java heap space, while running mvn sonar:sonar -X

i am trying to do the code analysis in sonar 2.11, using maven 3.

I am facing this error

java.lang.OutOfMemoryError: Java heap space.

i tried to increase the MAVEN_OPTS to -Xmx1024m -Xms512m -XX:MaxPermSize=256m but no use.

The project is of large size of about 900MB. I am using the command mvn sonar:sonar -X in maven 3. But the build is failure. I am not running the tests or nor using any surefire plugin in my superPOM. So i am unable to find the cause of the problem. Please help me to figure out where the problem exixts. Thanks in advance... Here is the log...

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] PHOENIX JAVA MODULE COMPONENT ..................... SKIPPED
[INFO] PHOENIX JAVA COMPONENT ............................ FAILURE [1:27:23.969s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:27:26.229s
[INFO] Finished at: Fri Dec 14 14:14:24 IST 2012
[INFO] Final Memory: 287M/1016M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0:sonar (default-cli) on project XXX: Can not execute Sonar: Can not execute Findbugs: java.lang.OutOfMemoryError: Java heap space -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0:sonar (default-cli) on project XXX: Can not execute Sonar   
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    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:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Can not execute Sonar
    at org.codehaus.mojo.sonar.Bootstraper.executeMojo(Bootstraper.java:118)
    at org.codehaus.mojo.sonar.Bootstraper.start(Bootstraper.java:65)
    at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:90)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
Caused by: org.sonar.api.utils.SonarException: Can not execute Findbugs
    at org.sonar.plugins.findbugs.FindbugsExecutor.execute(FindbugsExecutor.java:120)
    at org.sonar.plugins.findbugs.FindbugsSensor.analyse(FindbugsSensor.java:58)
    at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:64)
    at org.sonar.batch.phases.Phases.execute(Phases.java:93)
    at org.sonar.batch.bootstrap.ProjectModule.doStart(ProjectModule.java:143)
    at org.sonar.batch.bootstrap.Module.start(Module.java:89)
    at org.sonar.batch.bootstrap.BatchModule.analyze(BatchModule.java:110)
    at org.sonar.batch.bootstrap.BatchModule.analyze(BatchModule.java:105)
    at org.sonar.batch.bootstrap.BatchModule.doStart(BatchModule.java:100)
    at org.sonar.batch.bootstrap.Module.start(Module.java:89)
    at org.sonar.batch.bootstrap.BootstrapModule.doStart(BootstrapModule.java:96)
    at org.sonar.batch.bootstrap.Module.start(Module.java:89)
    at org.sonar.batch.Batch.execute(Batch.java:74)
    at org.sonar.maven3.SonarMojo.executeBatch(SonarMojo.java:147)
    at org.sonar.maven3.SonarMojo.execute(SonarMojo.java:136)
    at org.codehaus.mojo.sonar.Bootstraper.executeMojo(Bootstraper.java:113)
    ... 23 more
Caused by: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space
    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:232)
    at java.util.concurrent.FutureTask.get(FutureTask.java:91)
    at org.sonar.plugins.findbugs.FindbugsExecutor.execute(FindbugsExecutor.java:112)
    ... 38 more
Caused by: java.lang.OutOfMemoryError: Java heap space
    at java.util.ArrayList.<init>(ArrayList.java:112)
    at edu.umd.cs.findbugs.ba.Frame.<init>(Frame.java:110)
    at edu.umd.cs.findbugs.ba.vna.ValueNumberFrame.<init>(ValueNumberFrame.java:58)
    at edu.umd.cs.findbugs.ba.vna.ValueNumberAnalysis.createFact(ValueNumberAnalysis.java:148)
    at edu.umd.cs.findbugs.ba.vna.ValueNumberAnalysis.createFact(ValueNumberAnalysis.java:55)
    at edu.umd.cs.findbugs.ba.Dataflow.execute(Dataflow.java:309)
    at edu.umd.cs.findbugs.classfile.engine.bcel.ValueNumberDataflowFactory.analyze(ValueNumberDataflowFactory.java:72)
    at edu.umd.cs.findbugs.classfile.engine.bcel.ValueNumberDataflowFactory.analyze(ValueNumberDataflowFactory.java:47)
    at edu.umd.cs.findbugs.classfile.impl.AnalysisCache.analyzeMethod(AnalysisCache.java:332)
    at edu.umd.cs.findbugs.classfile.impl.AnalysisCache.getMethodAnalysis(AnalysisCache.java:282)
    at edu.umd.cs.findbugs.ba.ClassContext.getMethodAnalysis(ClassContext.java:942)
    at edu.umd.cs.findbugs.ba.ClassContext.getValueNumberDataflow(ClassContext.java:361)
    at edu.umd.cs.findbugs.detect.FindInconsistentSync2.findObviouslyLockedCallSites(FindInconsistentSync2.java:963)
    at edu.umd.cs.findbugs.detect.FindInconsistentSync2.visitClassContext(FindInconsistentSync2.java:311)
    at edu.umd.cs.findbugs.DetectorToDetector2Adapter.visitClass(DetectorToDetector2Adapter.java:68)
    at edu.umd.cs.findbugs.FindBugs2.analyzeApplication(FindBugs2.java:979)
    at edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:230)
    at org.sonar.plugins.findbugs.FindbugsExecutor$FindbugsTask.call(FindbugsExecutor.java:137)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :XXX

Upvotes: 7

Views: 8738

Answers (3)

AatmanKothari
AatmanKothari

Reputation: 113

Updating the JDK version on jenkins server to 64 bit solved this issue for me.

Try setting the parameter set SONAR_SCANNER_OPTS=-Xmx1024m in sonar-scanner.bat or export SONAR_SCANNER_OPTS=-Xmx1024m if invoking through shell script.

Upvotes: 0

sunnyX
sunnyX

Reputation: 87

I had similar problem where it used to hung on Journal Flushing and ultimately timeout at whatever the value i set in Findbags Java default timeout in sonarqube or give Out of memory error.

I resolved this by using the following options while running the sonar maven command:- MAVEN_OPTS="-Xms256m -Xmx4096m -XX:+UseSerialGC"

This has fixed the issue for me.

The post which helped me:- http://sonarqube-archive.15.x6.nabble.com/SonarQube-terminates-at-quot-Journal-Flusher-quot-warning-and-heap-size-error-td5027066.html

Upvotes: 1

This is a well-known problem: Findbugs is really memory hungry, so I'm not surprised that with a 900MB project, you have to increase the JVM memory options quite a lot.

3 things you can do:

  1. increase again the JVM memory options till it is OK

  2. reduce the amount of activated Findbugs rules in your Sonar quality profile

  3. refactor your project is smaller modules so that each module requires less memory to get analyzed by Findbugs

If I were you, I'd really go for at least option #3, because 900MB for a single project is really huge.

Upvotes: 5

Related Questions