2

I am using jenkins for making build by using Ant. I am also configuring sonar on this jenkins job via 'Invoke Standalone Sonar Analysis". Everything is going fine till build making process and build successfully created. Now sonar execution is started and after some time i got an error

"Exception in thread "main" org.sonar.batch.bootstrapper.BootstrapException: java.lang.OutOfMemoryError: Java heap space

Build step 'Invoke Standalone Sonar Analysis' marked build as failure "...

What all i have done to fix this issue are:

  1. Increasing java heap size via

    Replaced %SONAR_RUNNER_OPTS% with -Xms256m -Xmx1024m in sonar-runner.bat file of sonar.

  2. Modify Sonar_Way quality profile and put only one or two rules active in this so that to avoid rule voilation.

then run build but still getting same java heap error. One more thing i would add on this is my project source folder size is around 40mb means its a big project comparatively.

Can anyboby help me out on this?? What else should i do to get this done. Your revert will be appreciable.. Thanks in Advance..

shekhar verma
  • 489
  • 2
  • 9
  • 22
  • Can you copy-paste the part of the log where the analysis fails with the OOMError? Also, can you detail more your Sonar configuration? (version, plugins that you use, ...etc) And lastly: is your project a multi-module project or a single module project? (40Mb of sources is really huge for a single module project) – Fabrice - SonarSource Team Feb 08 '13 at 10:07
  • Hi Fabrice, below are the error logs and sonar details you are asking for.. – shekhar verma Feb 08 '13 at 10:18
  • 11:40:53.371 INFO p.PhasesTimeProfiler - Execute decorators... Total time: 9:42.926s Final Memory: 20M/247M Exception in thread "main" org.sonar.batch.bootstrapper.BootstrapException: java.lang.OutOfMemoryError: Java heap space at org.sonar.runner.Runner.delegateExecution(Runner.java:189) at org.sonar.runner.Runner.execute(Runner.java:78) at org.sonar.runner.Main.main(Main.java:61) Caused by: java.lang.OutOfMemoryError: Java heap space at java.util.ArrayList.(ArrayList.java:112) – shekhar verma Feb 08 '13 at 10:31
  • OTHER DETAILS......sonar configuration and pluign details-- sonar-version--3.2 plugins m suing are: 1.pdf-report-plugin 2.build-breaker-plugin 3.branding-plugin 4.jira-plugin 5.quality-index-plugin 6.technicaldebt-plugin 7.web-plugin and this project have only one module – shekhar verma Feb 08 '13 at 10:33
  • See my answer here: http://stackoverflow.com/questions/17271405/unable-to-execute-sonar-caused-by-java-heap-space/20481806#20481806 – Ryan Shillington Dec 09 '13 at 22:08

1 Answers1

2

Here are some other things you can try:

  • Remove all the following addionnal plugins: PDF, build-breaker, quality-index, technical debt. And try a new analysis.

  • Increase again the Java heap size (-Xms512m -Xmx1024m)

  • Use "sonar.exclusions" to exclude parts of your code, and see the max amount of source code that you can analyse at once without failing

  • Split your big project into small modules and use the multi-module feature of Sonar

  • Fabrice, Thanks for your answer, it works for me. i have removed additional plugins and make build again this time sonar successfully works but something is there which is not clear to me, please clarify me on below points: – shekhar verma Feb 12 '13 at 06:08
  • 1. When i separately deployed my project on sonar without jenkins it works fine and successfully deployed on sonar alongwith all the additional plugins then what could be the reason for its failure while deploying through jenkins even jenkins build was successful,only sonar analysis failed. – shekhar verma Feb 12 '13 at 06:11
  • 2. Second time, i remove all the build making configurations from jenkins like Ant, windows batch command etc and only configured sonar via "Invoke Standalone sonar analysis" and provide source code, project name etc by project properties and make build again, this also results in build failure due to same error"java heap space". – shekhar verma Feb 12 '13 at 06:12
  • so i would like to ask where was the problem, at sonar end or at jenkins end?? Is there any other way to increase heap size(for sonar or jenkins whichever required) as i want to add these additional plugins also. Please revert in case you have something on this. and Thanks again.. – shekhar verma Feb 12 '13 at 06:12