简体   繁体   English

sonarRunner java.lang.OutOfMemoryError:PermGen空间

[英]sonarRunner java.lang.OutOfMemoryError: PermGen space

Environment: 环境:
1. Linux 1. Linux
2. Gradle 1.6/7 2.摇篮1.6 / 7
3. Language - Java 3.语言-Java

gradle clean build jacocoTestReport - working fine. gradle clean build jacocoTestReport-运行正常。

Recently followed the documentation provided by SonarQube installation at: http://docs.sonarqube.org/display/SONAR/Running+SonarQube+as+a+Service+on+Linux (sonar start, sonar status, sonar stop etc)...commands will work at this point. 最近,遵循了SonarQube安装提供的文档: http ://docs.sonarqube.org/display/SONAR/Running+SonarQube+as+a+Service+on+Linux(声纳启动,声纳状态,声纳停止等)。 .commands此时将起作用。

Changed gradle build script acc. 更改Gradle构建脚本ACC。 to Gradle SonarRunner help page at: http://www.gradle.org/docs/current/userguide/sonar_runner_plugin.html 到Gradle SonarRunner帮助页面: http : //www.gradle.org/docs/current/userguide/sonar_runner_plugin.html

While running sonarRunner task - I get the following error: 运行sonarRunner任务时-出现以下错误:

: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 ie - sonar/conf/sonar.properties - everything looks correct - sonar/conf/wrapper.properties - contains valid values for JAVA opts ie 将声纳安装在/ production / c123456 / sonar上,即-sonar / conf / sonar.properties-一切看起来正确-sonar / conf / wrapper.properties-包含JAVA opts的有效值,即

# 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
  1. Can someone help what I could be missing to get this error message - PermGen space issue NOTE : This was happening from one Linux machine, so I tried installing Sonar on other Linux machine, still got the same error message. 有人可以帮我解决这个错误消息的问题-PermGen空间问题注意 :这是在一台Linux机器上发生的,因此我尝试在另一台Linux机器上安装Sonar,仍然收到相同的错误消息。

  2. I installed SonarQube/Runner on my own local Windows machine and pointed build.gradle sonarRunner section to use host url as my local machine / host url my machine name (fqdn) with port (:9000) etc and same for jdbc h2 tcp way. 我在自己的本地Windows计算机上安装了SonarQube / Runner,并指向build.gradle sonarRunner部分以将主机URL用作本地计算机/主机URL,将我的计算机名称(fqdn)与端口(:9000)等使用,对于jdbc h2 tcp方式也是如此。

    While running "gradle clean build jacocoTestReport sonarRunner", it passes the above error but gives me another strange one. 在运行“ gradle clean build jacocoTestReport sonarRunner”时,它通过了上述错误,但给了我另一个奇怪的错误。 C:\\work is my workspace where I have checked out the project: Project_A_Svc (service project - Java source). C:\\ work是我签出项目的工作空间:Project_A_Svc(服务项目-Java源)。

    :sonarRunner FAILED :sonarRunner失败

    FAILURE: Build failed with an exception. 失败:构建失败,发生异常。

    • What went wrong: Execution failed for task ':sonarRunner'. 出了什么问题:任务':sonarRunner'的执行失败。

      org.sonar.runner.RunnerException: The folder 'C:\\work\\Project_A_Svc\\src\\main\\java' does not exist for 'project_a_svc:project_a_svc' project (base directory = C:\\work\\Project_A_Svc) org.sonar.runner.RunnerException:“ project_a_svc:project_a_svc”项目的文件夹“ C:\\ work \\ Project_A_Svc \\ src \\ main \\ java”不存在(基本目录= C:\\ work \\ Project_A_Svc)

    • Try: Run with --stacktrace option to get the stack trace. 尝试:使用--stacktrace选项运行以获取堆栈跟踪。 Run with --info or --debug option to get more log output. 使用--info或--debug选项运行以获取更多日志输出。

    BUILD FAILED 建立失败

    Total time: 38.124 secs 总时间:38.124秒

Why Gradle is trying to look for "src/main/java" when my source code doesn't even have that folder structure. 当我的源代码甚至没有该文件夹结构时, 为什么Gradle试图寻找“ src / main / java”。 Gradle default structure is to use "src/main/java" for java source code location but my build.gradle does have sourceSets section where I have mentioned the location to find java source. Gradle的默认结构是对Java源代码位置使用“ src / main / java”,但是我的build.gradle确实有sourceSets部分,在此我提到了查找Java源代码的位置。 I have tried multiple ways to set source Dirs for src java / tests but it's still trying to look for "src/main/java". 我尝试了多种方法来为src java / tests设置源Dirs,但它仍在尝试寻找“ src / main / java”。

build.gradle snapshost 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 within build.gradle is: build.gradle中的sonarRunner部分是:

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? 有什么帮助吗? Thanks a lot. 非常感谢。

I got some progress. 我取得了一些进展。

Steps 脚步

  1. DIDN'T change anything in sonar/conf/sonar.properties, wrapper.properties, sonar-runner/conf/sonar-runner.properties. 不要更改sonar / conf / sonar.properties,wrapper.properties,sonar-runner / conf / sonar-runner.properties中的任何内容。 MADE sure the host url value is same in sonar.properties and sonar-runner.properties. 确保主机URL值在sonar.properties和sonar-runner.properties中。

  2. Go to the workspace (where you have source code installed). 转到工作区(已安装源代码的位置)。

  3. Ran sonar-runner (an executable) - it will show the path/file It gave the error that I need sonar-project.properties as I was missing some variables required by Sonar. Ran sonar-runner (一个可执行文件)-它会显示路径/文件它给出了我需要sonar-project.properties的错误,因为我缺少Sonar所需的一些变量。

    Used the link 使用了链接

  4. Found SCM Provider not set. 发现未设置SCM提供程序。 Used the link: http://jira.codehaus.org/browse/ACT-1714 to resolve it. 使用链接: http : //jira.codehaus.org/browse/ACT-1714来解决它。

  5. ran sonar-runner again, it went fine. 再次运行声纳运行器,一切正常。 (NOTE: This command is different than running sonarRunner as that's Gradle's sonar runner task). (注意:此命令与运行sonarRunner不同,因为这是Gradle的声纳运行器任务)。

  6. Went to SonarQube dashboard and there's stuff showing now. 进入SonarQube仪表板,现在有东西显示。

PENDING for tomorrow: 等待明天:

  1. To the following at Linux command line and from Jenkins (job calling gradle tasks). 在Linux命令行和Jenkins处执行以下操作(调用gradle任务)。 gradle clean build jacocoTestReport sonarRunner gradle clean build jacocoTestReport sonarRunner

Update: 更新:

  • Tried running: 尝试运行:

gradle clean build jacocoTestReport - works gradle clean build jacocoTestReport-工程

gradle clean build jacocoTestReport sonarRunner -- Fails saying src/main/java doesn't exist gradle clean build jacocoTestReport sonarRunner-失败,说src / main / java不存在

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

gradle clean build jacocoTestReport sonarRunner -Dsonar.sources="src/java,test/java,src/java-test" -- DID NOT WORKED (PermGen java error) gradle clean build jacocoTestReport sonarRunner -Dsonar.sources =“ src / java,test / java,src / java-test” –无效(PermGen java错误)

gradle clean build jacocoTestReport sonarRunner -Dsonar.sources="src/java" -- DID NOT WORKED (PermGen java error) gradle clean build jacocoTestReport sonarRunner -Dsonar.sources =“ src / java”-不起作用(PermGen java错误)

gradle clean build jacocoTestReport sonarRunner -Dsonar.sources=src/java -- DID NOT WORKED (PermGen java error) gradle clean build jacocoTestReport sonarRunner -Dsonar.sources = src / java-无效(PermGen java错误)

gradle sonarRunner -Dsonar.sources=src/java,test/java,src/java-test -- DID NOT WORKED (Error is charset can't read or import - charset UTF-8 or whatever I end up setting for sonar.sourceEncoding) gradle sonarRunner -Dsonar.sources = src / java,test / java,src / java-test-不工作(错误是字符集无法读取或导入-字符集UTF-8或我最终为sonar.sourceEncoding设置的内容)

gradle clea build jacocoTestReport -- WORKED gradle clea build jacocoTestReport-已解决

then 然后

gradle sonarRunner -Dsonar.sources="src/java" -- WORKED gradle sonarRunner -Dsonar.sources =“ src / java” -已解决

I have tried setting MaxPernGen in sonar/conf/wrapper.properties to various values like 128, 512, 1024, 2048, ... upto 8000m ... didn't work in resolving the following error - while running all gradle tasks in one command. 我曾尝试将sonar / conf / wrapper.properties中的MaxPernGen设置为128、512、1024、2048等各种值,直到8000m ...无法解决以下错误-同时运行所有gradle任务命令。

: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

Wondering why I'm getting this error as soon as I run: 想知道为什么我在运行时立即收到此错误:

:gradle clean build jacocoTestReport sonarRunner" :gradle clean build jacocoTestReport sonarRunner“




OK - got PermGen Memory issue resolved. OK -得到了PermGen的内存问题解决。

Steps : 1. In my ~/.bashrc or ~/.bash_profile. 步骤 :1.在我的〜/ .bashrc或〜/ .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. 运行“哪个gradle”或基本上找到使用哪个gradle文件(shell或.bat)。 Go to that path and open "gradle" / "gradle.bat" (for windows) file. 转到该路径,然后打开“ gradle” /“ gradle.bat”(对于Windows)文件。

  2. Make the following changes. 进行以下更改。

     DEFAULT_JVM_OPTS="$JAVA_OPTS $GRADLE_OPTS" 
  3. Do ". ~/.bash_profile" or ". ~/.bashrc" .... --OR open a new putty session. 执行“。〜/ .bash_profile”或“。〜/ .bashrc” ....-或打开一个新的腻子会话。

  4. Make sure PATH variable has gradle HOME / bin in it (Linux/Windows) 确保PATH变量中包含gradle HOME / bin(Linux / Windows)

  5. Ran the following command (this time didn't show PermGen error which I got earlier) from workspace: 从工作区运行以下命令(这次没有显示我之前得到的PermGen错误):

    gradle clean build jacocoTestReport sonarRunner gradle clean build jacocoTestReport sonarRunner

    :) Time to go home early today. :)今天早点回家。

  6. Other similar variables are: GRADLE_OPTS / JAVA_OPTS / SONAR_RUNNER_OPTS (where -XX:Max.. value can be set) at server(putty session level) or in IDEs or in Jenkins. 其他类似的变量包括:服务器(putty会话级别)或在IDE或Jenkins中的GRADLE_OPTS / JAVA_OPTS / SONAR_RUNNER_OPTS(可设置-XX:Max ..值)。

Thanks Allyn for the hint. 感谢Allyn的提示。

如果您使用Gradle Wrapper,则可以在此处指定GRADLE_OPTS,这在Jenkins上也应适用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM