27

I am getting OutOfMemoryException while performing sonar analysis on my project. Below is the stack trace:

14:55:55.433 DEBUG - Release semaphore on project : org.sonar.api.resources.Project@5a7b5cb8[id=1,key=myProj_web,qualifier=TRK], with key batch-myProj_web
14:55:55.711 DEBUG - To prevent a memory leak, the JDBC Driver [com.mysql.jdbc.Driver] has been forcibly deregistered

INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 12:48.979s
Final Memory: 33M/910M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
        at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
        at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
        at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
        at org.sonar.runner.api.Runner.execute(Runner.java:100)
        at org.sonar.runner.Main.executeTask(Main.java:70)
        at org.sonar.runner.Main.execute(Main.java:59)
        at org.sonar.runner.Main.main(Main.java:53)
Caused by: org.sonar.api.utils.SonarException: Can not execute Findbugs
        at org.sonar.plugins.findbugs.FindbugsExecutor.execute(FindbugsExecutor.java:154)
        at org.sonar.plugins.findbugs.FindbugsSensor.analyse(FindbugsSensor.java:59)
        at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:79)
        at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:70)
        at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:131)
        at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:178)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
        at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:199)
        at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:194)
        at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:187)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
        at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:56)
        at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:44)
        at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:82)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
        at org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapContainer.java:175)
        at org.sonar.batch.bootstrap.BootstrapContainer.doAfterStart(BootstrapContainer.java:163)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
        at org.sonar.batch.bootstrapper.Batch.startBatch(Batch.java:92)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:74)
        at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
        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.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
        ... 9 more
Caused by: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
        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:146)
        ... 38 more
Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded
        at edu.umd.cs.findbugs.util.Strings.escapeXml(Strings.java:167)
        at edu.umd.cs.findbugs.xml.XMLAttributeList.getQuotedAttributeValue(XMLAttributeList.java:132)
        at edu.umd.cs.findbugs.xml.XMLAttributeList.toString(XMLAttributeList.java:111)
        at edu.umd.cs.findbugs.xml.OutputStreamXMLOutput.openTag(OutputStreamXMLOutput.java:112)
        at edu.umd.cs.findbugs.SourceLineAnnotation.writeXML(SourceLineAnnotation.java:887)
        at edu.umd.cs.findbugs.ClassAnnotation.writeXML(ClassAnnotation.java:192)
        at edu.umd.cs.findbugs.BugInstance.writeXML(BugInstance.java:2292)
        at edu.umd.cs.findbugs.SortedBugCollection.writeXML(SortedBugCollection.java:576)
        at edu.umd.cs.findbugs.SortedBugCollection.writeXML(SortedBugCollection.java:497)
        at edu.umd.cs.findbugs.XMLBugReporter.finish(XMLBugReporter.java:46)
        at edu.umd.cs.findbugs.DelegatingBugReporter.finish(DelegatingBugReporter.java:81)
        at edu.umd.cs.findbugs.DelegatingBugReporter.finish(DelegatingBugReporter.java:81)
        at edu.umd.cs.findbugs.DelegatingBugReporter.finish(DelegatingBugReporter.java:81)
        at edu.umd.cs.findbugs.FindBugs2.analyzeApplication(FindBugs2.java:1256)
        at edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:282)
        at org.sonar.plugins.findbugs.FindbugsExecutor$FindbugsTask.call(FindbugsExecutor.java:201)
        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:662)

I tried increasing memory but the problem still exists. I have used following options while running sonar: set SONAR_RUNNER_OPTS=-Xmx1024m -XX:MaxPermSize=512m

barfuin
  • 16,865
  • 10
  • 85
  • 132
Yasin
  • 1,906
  • 1
  • 21
  • 37
  • How do I identify which component of SonarQube is having the problem? Is it the duplicate code checker plugin or something else? – Yasin Jun 23 '14 at 10:24
  • Still I would like to know how to identify the component which was last executed just before the exception. Is there any way to identify it using the logs or the stack trace above? I am not able to figure it out though. – Yasin Jun 24 '14 at 08:30
  • [This similar question](http://stackoverflow.com/q/10104443/1005481) may also be of help. – barfuin Jun 24 '14 at 08:58

1 Answers1

15

OK, after doing some more research I got it right. I had to do some setup, though.

  1. Skip the package design analysis, sonar.skipPackageDesign=true
  2. Remove the entries for lib/test directory in your project's properties file
  3. Give some more memory set SONAR_RUNNER_OPTS=-Xmx1536m -XX:MaxPermSize=512m
  4. Optionally you can disable design analysis by using sonar.skipDesign=true
  5. Restart SonarQube services and you should be good now :)

To read more, please refer this post

Micha Wiedenmann
  • 19,979
  • 21
  • 92
  • 137
Yasin
  • 1,906
  • 1
  • 21
  • 37
  • 1
    tried all thos settings via MAVEN_OPTS from Jenkins, but unfortunately no success :( – gvasquez Jan 29 '18 at 19:07
  • Even the sonar specific settings using the -D flag for Maven: -Dsonar.skipPackageDesign=true -Dsonar.skipDesign=true – gvasquez Jan 29 '18 at 19:08
  • 1
    Try it on your local machine first. Please note that this is an old answer, things might have changed in Sonar latest version. Please consult their documentation as well. – Yasin Jan 30 '18 at 09:47
  • /d:sonar.skipPackageDesign=true should be added in the begin command ;) – Fabito Dec 10 '18 at 16:06
  • Any ideas if you don't have permissions to restart sonar cube? Is there an additional parameter I can pass or something? – JGleason Oct 05 '20 at 18:52