2015-12-07 118 views
5

從3.3.2升級到Sonarqube 5.1.2後,我需要用jdk 1.6構建的項目的maven版本失敗:org/sonar/api/utils/SonarException:不支持的major.minor版本51.0

build 03-Dec-2015 19:33:10 [INFO] ------------------------------------------------------------------------ 
build 03-Dec-2015 19:33:10 [ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project my_project: Execution default-cli of goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar failed: An API incompatibility was encountered while executing org.codehaus.mojo:sonar-maven-plugin:2.6:sonar: java.lang.UnsupportedClassVersionError: org/sonar/api/utils/SonarException : Unsupported major.minor version 51.0 
build 03-Dec-2015 19:33:10 [ERROR] ----------------------------------------------------- 
build 03-Dec-2015 19:33:10 [ERROR] realm = plugin>org.codehaus.mojo:sonar-maven-plugin:2.6 
build 03-Dec-2015 19:33:10 [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy 
build 03-Dec-2015 19:33:10 [ERROR] urls[0] = file:/tmp/org/codehaus/mojo/sonar-maven-plugin/2.6/sonar-maven-plugin-2.6.jar 
build 03-Dec-2015 19:33:10 [ERROR] urls[1] = file:/tmp/org/apache/maven/shared/maven-dependency-tree/2.1/maven-dependency-tree-2.1.jar 
build 03-Dec-2015 19:33:10 [ERROR] urls[2] = file:/tmp/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar 
build 03-Dec-2015 19:33:10 [ERROR] urls[3] = file:/tmp/org/codehaus/plexus/plexus-interpolation/1.11/plexus-interpolation-1.11.jar 
build 03-Dec-2015 19:33:10 [ERROR] urls[4] = file:/tmp/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar 
build 03-Dec-2015 19:33:10 [ERROR] urls[5] = file:/tmp/org/eclipse/aether/aether-util/0.9.0.M2/aether-util-0.9.0.M2.jar 
build 03-Dec-2015 19:33:10 [ERROR] urls[6] = file:/tmp/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar 
build 03-Dec-2015 19:33:10 [ERROR] urls[7] = file:/tmp/org/codehaus/plexus/plexus-utils/1.5.5/plexus-utils-1.5.5.jar 
build 03-Dec-2015 19:33:10 [ERROR] urls[8] = file:/tmp/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar 
build 03-Dec-2015 19:33:10 [ERROR] urls[9] = file:/tmp/org/codehaus/sonar/runner/sonar-runner-api/2.4/sonar-runner-api-2.4.jar 
build 03-Dec-2015 19:33:10 [ERROR] urls[10] = file:/tmp/commons-lang/commons-lang/2.6/commons-lang-2.6.jar 
build 03-Dec-2015 19:33:10 [ERROR] urls[11] = file:/tmp/com/google/guava/guava/10.0.1/guava-10.0.1.jar 
build 03-Dec-2015 19:33:10 [ERROR] urls[12] = file:/tmp/com/google/code/findbugs/jsr305/2.0.3/jsr305-2.0.3.jar 
build 03-Dec-2015 19:33:10 [ERROR] Number of foreign imports: 1 
build 03-Dec-2015 19:33:10 [ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]] 
build 03-Dec-2015 19:33:10 [ERROR] 
build 03-Dec-2015 19:33:10 [ERROR] ----------------------------------------------------- 
build 03-Dec-2015 19:33:10 [ERROR] -> [Help 1] 

似乎是一個兼容性問題,任何想法? 指向老聲納它仍然正常工作,指向新的聲納,我明白了。

感謝, 羅伯託

回答

8

運行分析正如你可以在"Requirements" page"SonarQube 5.0 Upgrade Guide"閱讀,你至少需要Java 7的運行SonarQube分析。

您可以隨時使用Java 6構建(編譯,測試等)您的項目,但是您需要配置SonarQube分析以使用Java 7或更高版本。

+1

究竟如何配置聲納的分析使用Java 8,而該項目仍然是Java 7的?我沒有找到像sonar.java.home或類似的任何屬性... – dokaspar

2

SonarQube 5.x的需要Java 7運行服務器和運行分析。

它仍然會分析項目建設與Java 6,但你應該使用Java 7

0

我陷入了幾乎同樣的問題,通過maven對Jenkins運行我的Sonar分析。在某些時候,得到成功的項目分析開始失敗而:

  • SonarQube服務器並沒有改變(版本4.5.6)
  • 詹金斯工作的配置並沒有改變(Maven的工作配置了JDK 1.7.0.45)
  • Maven的配置並沒有改變

這是我得到:

org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/sonarsource/scanner/maven/SonarQubeMojo : Unsupported major.minor version 52.0 
17:27:29 [ERROR] ----------------------------------------------------- 
17:27:29 [ERROR] realm = plugin>org.sonarsource.scanner.maven:sonar-maven-plugin:3.1.1 
17:27:29 [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy 
17:27:29 [ERROR] urls[0] = file:/c:/tools/.m2/repository/org/sonarsource/scanner/maven/sonar-maven-plugin/3.1.1/sonar-maven-plugin-3.1.1.jar 
17:27:29 [ERROR] urls[1] = file:/c:/tools/.m2/repository/org/apache/maven/shared/maven-dependency-tree/2.2/maven-dependency-tree-2.2.jar 
17:27:29 [ERROR] urls[2] = file:/c:/tools/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar 
17:27:29 [ERROR] urls[3] = file:/c:/tools/.m2/repository/org/eclipse/aether/aether-util/0.9.0.M2/aether-util-0.9.0.M2.jar 
17:27:29 [ERROR] urls[4] = file:/c:/tools/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar 
17:27:29 [ERROR] urls[5] = file:/c:/tools/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar 
17:27:29 [ERROR] urls[6] = file:/c:/tools/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.22/plexus-utils-3.0.22.jar 
17:27:29 [ERROR] urls[7] = file:/c:/tools/.m2/repository/org/sonarsource/scanner/api/sonar-scanner-api/2.7/sonar-scanner-api-2.7.jar 
17:27:29 [ERROR] urls[8] = file:/c:/tools/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar 
17:27:29 [ERROR] urls[9] = file:/c:/tools/.m2/repository/com/google/code/findbugs/jsr305/2.0.3/jsr305-2.0.3.jar 
17:27:29 [ERROR] Number of foreign imports: 1 
17:27:29 [ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]] 

的ISSU e爲通過之間的Java版本不匹配造成這裏:

  • 詹金斯工作與JDK 1.7.x
  • 聲納的Maven插件版本3.1.1正在與JDK 1.8.x的編譯執行

插件的版本沒有在pom.xml中顯式設置,所以當作業使用此版本的插件時分析開始失敗。

由於很多原因,作業JDK無法升級到1.8,所以sonar-maven-plugin的版本被固定爲3.0.2。

0

這是正確的,您需要java 1.7版本。確保你已經更新了jdk版本,而不是jre。

首先驗證用於拾取jdk版本的env變量。

javac -version

輸出:

Picked up _JAVA_OPTIONS: -Xmx512M javac 1.7.0_80

轉到命令行,並按照下面的變化。

Set JAVA_OPTIONS=C:\Program Files\Java\jdk1.7.0_80

Set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_80 set PATH=%JAVA_HOME%\bin;%PATH%

+0

這個答案可以通過使用一些[代碼格式化](https://meta.stackexchange.com/questions/22186/how-do-i -format-我的代碼塊)。 – Ben

相關問題