mavenjenkinssonarqubesonarscannersonar-maven-plugin

Getting API compatibility error when try to analyze a java application (Java 8)with Sonarqube 9.9


this is the error i get Failed to execute goal [32morg.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar[m [1m(default-cli)[m on project[m: [1;31mExecution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar: java.lang.UnsupportedClassVersionError: org/sonar/batch/bootstrapper/EnvironmentInformation has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0[m

I have tried multiple options, in the POM.XML adding Java 1.8 to the properties and using a specific sonar-maven plugin maven versions, but the error persists. here is the pertinent part of my POM.XML

<properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <sonar.host.url>
            XXX
        </sonar.host.url>
    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.1</version>
                </plugin>
                <plugin>
                    <groupId>org.sonarsource.scanner.maven</groupId>
                    <artifactId>sonar-maven-plugin</artifactId>
                    <version>3.6.0.1398</version>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>0.8.7</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <modules>
        <module>sbom</module>
    </modules>
</project>

I have tried multiple options, in the POM.XML adding Java 1.8 to the properties and using a specific sonar-maven plugin maven versions 3.8, 3.6, but the error persists. here is the pertinent part of my POM.XML, is there a way to get past this???


Solution

  • You need to use at least Java 11.

    See List of Java class file format major version numbers? for what the numbers mean.