org / sonar / api / utils / SonarException:不支持的major.minor版本51.0

时间:2015-12-07 10:40:42

标签: sonarqube

从3.3.2升级到Sonarqube 5.1.2之后,我需要使用jdk 1.6构建的项目的maven构建失败了:

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]

似乎是一个兼容性问题,任何想法? 指向旧的声纳它仍然可以正常工作,指向新的声纳,我明白了。

谢谢, 罗伯特

4 个答案:

答案 0 :(得分:8)

您可以在"Requirements" page"SonarQube 5.0 Upgrade Guide"中阅读,至少需要使用Java 7来运行SonarQube分析。

您始终可以使用Java 6构建(编译,测试等)您的项目,但是您需要将SonarQube分析配置为使用Java 7或更高版本。

答案 1 :(得分:2)

SonarQube 5.x要求java 7运行服务器并运行分析。

它仍将分析使用java 6构建的项目,但您应该使用java 7运行分析。

答案 2 :(得分:0)

我遇到了几乎同样的问题,通过maven在Jenkins上运行我的声纳分析。在某些时候,项目分析在以下情况下开始失败:

  • SonarQube Server未更改(版本4.5.6)
  • Jenkins作业配置未更改(使用JDK 1.7.0.45配置Maven作业)
  • 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]]

这个问题是由于java版本不匹配导致的:

  • Jenkins Job使用JDK 1.7.x执行
  • 使用JDK 1.8.x编译的sonar-maven-plugin版本3.1.1

插件的版本未在pom.xml中明确设置,因此当作业使用此版本的插件时,分析开始失败。

由于许多原因,作业JDK无法升级到1.8,因此声纳-maven-plugin的版本固定为3.0.2。

答案 3 :(得分: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%