22

Environment details:

  • SonarQube 5.6
  • Apache Maven 3.3.9
  • Java version: 1.7.0_09

I integrated SonarQube plugin with java maven project like in pom.xml

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.sonarsource.scanner.maven</groupId>
                <artifactId>sonar-maven-plugin</artifactId>
                <version>3.0.2</version>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

While executing goal: mvn sonar:sonar -Dsonar.host.url=<url>

Getting exception:

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.2:sonar (default-cli) on project example-java-maven: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.2:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.2:sonar: java.lang.UnsupportedClassVersionError: org/sonar/batch/bootstrapper/EnvironmentInformation: Unsupported major.minor version 52.0 [ERROR] ----------------------------------------------------- [ERROR] realm = plugin>org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.2

Max Leske
  • 4,919
  • 6
  • 43
  • 51
user3492783
  • 221
  • 1
  • 2
  • 3

4 Answers4

26

SonarQube 5.6 requires at least Java 8 (see requirements). Note that this is not a just a requirement on the server side, it's also required on the client side where analysis are ran.

Like agabrys mentioned in his comment, the Unsupported major.minor is a classic Java error (see this thread).

Community
  • 1
  • 1
Nicolas B.
  • 6,979
  • 15
  • 29
2

I just ran into this problem myself. My solution since my code and platform being developed is currently only using Java 7, and cannot use Java 8, I decided to launch the previous release/tag (5.5) with:

See tags here: Tags for sonarqube at hub.docker.com

docker run -d --name sonarqube -p 9000:9000 -p 9092:9092 sonarqube:5.5

Ed Bragg
  • 108
  • 1
  • 4
1

You need at least JDK 1.8. Read more about major.minor version at: How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version

Community
  • 1
  • 1
agabrys
  • 7,875
  • 3
  • 25
  • 61
-1

To further extend agabrys' and Nicolas B's answers:

You need to go to oracle's website and download an jdk of version 8.

And configure jenkins' config.xml, which normally located in /var/lib/jenkins and add an jdk:

<jdk>
  <name>jdk1.8</name>
  <home>/usr/java/jdk1.8.0_144</home>
  <properties/>
</jdk>

in the section. Or you can add it in the jenkins web site at manage jenkins -> global tool configuration.

dotslashlu
  • 3,289
  • 3
  • 27
  • 56
  • The question is not about Jenkins. Btw. any JDK 8 is good., There is no requirement to use Oracle JDK. – agabrys Apr 24 '22 at 07:14