API incompatibility was encountered while executing org.sonarsource.scanner.maven

Hi Team,

I have successfully upgraded the sonarqube version from 6.7 to 9.9. After the upgrade, while doing the build I are getting the below mentioned error.
I have gone through the url : Understanding `java.lang.UnsupportedClassVersionError` . But didn’t find much information.

Could you please help us to resolve this issue. The java version using in the server is Java 17 and I used AWS code build to build the application

Downloaded: http://*.*.*.*:8081/repository/maven-public/org/sonarsource/scanner/api/sonar-scanner-api/2.16.3.1081/sonar-scanner-api-2.16.3.1081.jar (611 KB at 654.6 KB/sec)
[INFO] 13:27:00.922 Java 1.8.0_121 Oracle Corporation (64-bit)
[INFO] 13:27:00.924 Linux 4.14.291-218.527.amzn2.x86_64 (amd64)
[INFO] 13:27:00.924 MAVEN_OPTS= -Dmaven.wagon.httpconnectionManager.maxPerRoute=2
[INFO] 13:27:00.994 User cache: /root/.sonar/cache
[INFO] 13:27:01.334 Communicating with SonarQube Server 9.9.4.87374
[INFO] 13:27:01.379 Default locale: "en_US", source code encoding: "UTF-8"
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.705 s
[INFO] Finished at: 2024-03-21T13:27:01+00:00
[INFO] Final Memory: 14M/176M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.11.0.3922:sonar (default-cli) on project ****************: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.11.0.3922:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.11.0.3922: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
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.sonarsource.scanner.maven:sonar-maven-plugin:3.11.0.3922
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/root/.m2/repository/org/sonarsource/scanner/maven/sonar-maven-plugin/3.11.0.3922/sonar-maven-plugin-3.11.0.3922.jar
[ERROR] urls[1] = file:/root/.m2/repository/org/codehaus/plexus/plexus-sec-dispatcher/2.0/plexus-sec-dispatcher-2.0.jar
[ERROR] urls[2] = file:/root/.m2/repository/org/codehaus/plexus/plexus-utils/3.4.1/plexus-utils-3.4.1.jar
[ERROR] urls[3] = file:/root/.m2/repository/org/codehaus/plexus/plexus-cipher/2.0/plexus-cipher-2.0.jar
[ERROR] urls[4] = file:/root/.m2/repository/org/sonarsource/scanner/api/sonar-scanner-api/2.16.3.1081/sonar-scanner-api-2.16.3.1081.jar
[ERROR] urls[5] = file:/root/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

Hi,

Congrats on your upgrade! It was a long way to go, and I’m glad to hear you got through it. :slight_smile:

Now that you’ve upgraded, Java 17 isn’t just required on the server. You need it on the CI side too, and that’s what this error is telling you. Upgrade the Java on your build agents to get past this.

(Full disclosure: With 9.9 you could use Java 11 on your build agents, but you might as well go ahead and jump to 17 while you’re upgrading.)

 
Ann

Thanks for the update. one more query.
Which sonarqube version will support Java 8 in build agent ?

Hi,

Current versions all require Java 11 (9.9) or higher.

 
Ann