Org / sonar / api / utils / SonarException: Unsupported version of major.minor 51.0

after upgrading from 3.3.2 to Sonarqube 5.1.2, my maven build for the project, which should be built using jdk 1.6, fails:

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] 

seems like a compatibility issue, any ideas? Pointing to the old sonar, it still works fine, pointing to the new one, I get this.

Thanks Roberto

+5
source share
4 answers

As you can read on the Requirements> page or the SonarQube 5.0 Upgrade Guide , you need at least Java 7 to run the SonarQube analysis.

You can always create (compile, test, etc.) your project using Java 6, but then you need to configure SonarQube analysis to use Java 7 or higher.

+8
source

SonarQube 5.x requires java 7 to start the server and perform analysis.

It will still parse project builds using java 6, but you have to start the analysis using java 7.

+2
source

I fell into almost the same problem as my Jenkins sonar analysis via maven. At some point, the analysis of the project that worked started to fail, while:

  • SonarQube server has not changed (version 4.5.6)
  • Jenkins Job configuration has not changed (Maven Job configured with JDK 1.7.0.45)
  • Maven configuration has not changed

And here is what I got:

 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]] 

The problem is caused by Java version mismatch:

  • Jenkins Working with JDK 1.7.x
  • version of sonar-maven-plugin 3.1.1 compiled with JDK 1.8.x

The plugin version was not explicitly set in pom.xml, so the analysis started to fail when the task took this plugin version.

For many reasons, the JDK cannot be upgraded to 1.8, so the version of the sonar-maven plugin has been fixed to 3.0.2.

0
source

That's right, you need java version 1.7. Make sure you update the jdk version, not the jre.

First check which env variable is used to get the jdk version.

javac -version

output:

Picked up _JAVA_OPTIONS: -Xmx512M javac 1.7.0_80

Go to the command line and make the following changes.

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

or

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

0
source

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


All Articles