SonarRunner java.lang.OutOfMemoryError: PermGen space

Environment:
1. Linux
2. Gradle 1.6 / 7
3. Language - Java

gradle clean build jacocoTestReport - works fine.

Recently, the documentation provided by the SonarQube installation followed: http://docs.sonarqube.org/display/SONAR/Running+SonarQube+as+a+Service+on+Linux (starting sonar, sonar status, stopping sonar, etc.) ... teams will work at this moment.

Changed Gradle build script acc. on the Gradle SonarRunner help page at: http://www.gradle.org/docs/current/userguide/sonar_runner_plugin.html

When performing the sonarRunner job, I get the following error:

:sonarRunner 18:56:03.997 INFO - Load batch settings 18:56:04.140 INFO - User cache: /production/c123456/jenkins/.sonar/cache 18:56:04.146 INFO - Install plugins 18:56:04.851 INFO - Install JDBC driver 18:56:04.858 WARN - H2 database should be used for evaluation purpose only 18:56:04.858 INFO - Create JDBC datasource for jdbc:h2:tcp://devserver11.tr.company.com:9092/sonar 18:56:05.870 INFO - Initializing Hibernate :sonarRunner FAILED java.lang.OutOfMemoryError: PermGen space > Building-bash-3.2$ 

Installed sonar at / production / c123456 / sonar, i.e. - sonar /conf/sonar.properties - everything looks right - sonar / conf / wrapper.properties - contains valid values ​​for choosing JAVA, i.e.

 # Java Additional Parameters wrapper.java.additional.1=-Djava.awt.headless=true wrapper.java.additional.2=-XX:MaxPermSize=1024m wrapper.java.additional.3=-XX:+HeapDumpOnOutOfMemoryError wrapper.java.additional.4=-XX:+CMSClassUnloadingEnabled wrapper.java.additional.5=-XX:+UseConcMarkSweepGC # RECOMMENDED : uncomment if Java Virtual Machine is a JDK but not a JRE. To know which JVM you use, execute # 'java -version'. JDK displays 'Server VM'. wrapper.java.additional.4=-server # Initial Java Heap Size (in MB) wrapper.java.initmemory=512 # Maximum Java Heap Size (in MB) wrapper.java.maxmemory=1024 
  • Can someone help, what could I lose to get this error message - PermGen space problem This was happening on one Linux machine, so I tried installing Sonar on another Linux machine, still got the same error message.

  • I installed SonarQube / Runner on my own local Windows machine and pointed to the build.gradle sonarRunner section to use the host URL as my local computer / host address is my machine name (fqdn) with port (: 9000), etc. for jdbc h2 tcp.

    When running "gradle clean build jacocoTestReport sonarRunner", it skips the above error, but gives me another weird one. C: \ work is my workspace where I checked the project: Project_A_Svc (the service project is the source of Java).

    : sonarRunner FAILED

    FAILURE: build failed with exception.

    • What went wrong: Execution completed for task ': sonarRunner'.

      org.sonar.runner.RunnerException: folder 'C: \ work \ Project_A_Svc \ src \ main \ java' does not exist for project project_a_svc: project_a_svc (base directory = C: \ work \ Project_A_Svc)

    • Try: Run with the --stacktrace option to get a stack trace. Run with the -info or --debug option to get more log output.

    STRICTLY MALFUNCTIONAL

    Total time: 38.124 seconds

Why is Gradle trying to find "src / main / java" when there is no such folder structure in my source code. Gradle The default structure is to use "src / main / java" for the location of the Java source code, but my build.gradle has a sourceSets section where I mentioned the location to find the java source. I tried several ways to set the Dirs source for src java / tests, but it is still trying to find "src / main / java".

build.gradle snapshost

 apply plugin: 'java' apply plugin: 'sonar-runner' main { java { srcDir 'src/java' } } test { java { srcDir 'test/java' } } integrationTest { java { srcDir 'src/java-test' } } } 

and

sonarRunner section inside build.gradle:

 def sonarServerUrl = "devserver11.tr.company.com" sonarRunner { sonarProperties { property "sonar.host.url", "http://$sonarServerUrl:9000" // these are default settings for the in-memory database. Change if using a persistent DB. property "sonar.jdbc.url", "jdbc:h2:tcp://$sonarServerUrl:9092/sonar" property "sonar.jdbc.driverClassName", "org.h2.Driver" property "sonar.jdbc.username", "sonar" property "sonar.jdbc.password", "sonar" //properties ["sonar.sources"] += sourceSets.main.java.srcDirs //properties ["sonar.tests"] += sourceSets.test.java.srcDirs //---- properties["sonar.sources"] = "src/java" properties["sonar.tests"] = "test/java" } } 

Any help? Many thanks.

+1
source share
2 answers

I had some progress.

Steps

  • DOES NOT change anything in sonar /conf/sonar.properties, wrapper.properties, sonar-runner / conf / sonar-runner.properties. DONE so that the host url value is the same in sonar.properties and sonar-runner.properties.

  • Go to the workspace (where you have the source code installed).

  • Ran sonar-runner (executable file) - he will show the path / file This gave an error that I needed sonar -project.properties, because I missed some of the variables that Sonar needed.

    Link used

  • Found SCM provider not installed. Used the link: http://jira.codehaus.org/browse/ACT-1714 to solve this problem.

  • the sonar ran again, everything went well. (NOTE: This command is different from running sonarRunner as this Gradle sonar task).

  • I went to the SonarQube dashboard and where it is now displayed.

Waiting for tomorrow:

  1. To the Linux and Jenkins commands below (task gradle tasks). gradle clean build jacocoTestReport sonarRunner

Update:

  • Runs:

gradle clean build jacocoTestReport - works

gradle clean build jacocoTestReport sonarRunner - Cannot say src / main / java does not exist

gradle clean build jacocoTestReport sonarRunner -Dsonar.sources = src / java - WORKED

gradle clean build jacocoTestReport sonarRunner -Dsonar.sources = "src / java, test / java, src / java-test" - DOES NOT WORK (Java PermGen error)

gradle clean build jacocoTestReport sonarRunner -Dsonar.sources = "src / java" - DOES NOT WORK (Java PermGen error)

gradle clean build jacocoTestReport sonarRunner -Dsonar.sources = src / java - DOES NOT WORK (Java PermGen error)

gradle sonarRunner -Dsonar.sources = src / java, test / java, src / java-test - DOES NOT WORK (error in encoding cannot be read or imported - UTF-8 encoding or something like setting for sonar.sourceEncoding)

gradle clea build jacocoTestReport - WORKED

then

gradle sonarRunner -Dsonar.sources = "src / java" - WORKED

I tried to set MaxPernGen in sonar / conf / wrapper.properties to various values, such as 128, 512, 1024, 2048, ... up to 8000 m ... did not work when resolving the following error - when starting all Gradle tasks in one command .

 :sonarRunner FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':sonarRunner'. > java.lang.OutOfMemoryError: PermGen space * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED 

I wonder why I get this error immediately after starting:

: gradle clean build jacocoTestReport sonarRunner "




OK - the problem with PermGen Memory is resolved.

Actions : 1. In my ~ / .bashrc or ~ / .bash_profile. I created the following variable

 GRADLE_OPTS=" -XX:MaxPermSize=512m" 
  1. Run "which gradle" or basically find which gradle file (shell or .bat) is used. Go to this path and open the gradle file "/" gradle.bat "(for Windows).

  2. Make the following changes.

     DEFAULT_JVM_OPTS="$JAVA_OPTS $GRADLE_OPTS" 
  3. Make ". ~ / .Bash_profile" or ". ~ / .Bashrc" .... - Open a new putty session.

  4. Make sure the PATH variable has a Gradle HOME / bin in it (Linux / Windows)

  5. Run the following command (this time did not indicate the PermGen error that I received earlier) from the workspace:

    gradle clean build jacocoTestReport sonarRunner

    :) Time to go home early today.

  6. Other similar variables: GRADLE_OPTS / JAVA_OPTS / SONAR_RUNNER_OPTS (where -XX: The maximum value can be set) on the server (putty session level) in either the IDE or Jenkins.

Thanks Allyn for the tip.

+2
source

If you use the Wrapper Gradle, you can specify GRADLE_OPTS there, which should also work on Jenkins.

0
source

Source: https://habr.com/ru/post/1210202/


All Articles