SonarQube - Upgrade - java.lang.UnsupportedClassVersionError

We are experiencing issues with our SonarQube Upgrades.

Current Version:

  • Java Version: OpenJDK 11
  • Version: 7.9.2

New Version:

  • Java Version: OpenJDK 11
  • Version: 9.4

Issue:

SonarQube upgrade went successfully however jobs in Jenkins/GitHub Actions/ADO that were working fine with older version of SonarQube Starts failing with below error:

Both GitHub Actions and Jenkins agents have OpenJDK 8 as default and it will be used to perform the analysis.
GitHub Actions:

18:01:54.930 ERROR: Error during SonarQube Scanner execution
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
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
	at org.sonarsource.scanner.api.internal.IsolatedClassloader.loadClass(IsolatedClassloader.java:82)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	at org.sonarsource.scanner.api.internal.batch.DefaultBatchFactory.createBatch(DefaultBatchFactory.java:32)
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at com.sun.proxy.$Proxy0.execute(Unknown Source)
	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
	at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Error: Process completed with exit code 1.

Jenkins
Command: mvn --settings settings.xml --batch-mode test verify surefire-report:report-only sonar:sonar '-Dsonar.host.url=https://sonarqube.mycompany.com' '-Dsonar.login=****' '-Dsonar.password='

13:26:57  [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project devops-example: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184: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
13:26:57  [ERROR] -----------------------------------------------------
13:26:57  [ERROR] realm =    plugin>org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184
13:26:57  [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
13:26:57  [ERROR] urls[0] = file:/home/EntDevOps/.m2/repository/org/sonarsource/scanner/maven/sonar-maven-plugin/3.9.1.2184/sonar-maven-plugin-3.9.1.2184.jar
13:26:57  [ERROR] urls[1] = file:/home/EntDevOps/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar
13:26:57  [ERROR] urls[2] = file:/home/EntDevOps/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
13:26:57  [ERROR] urls[3] = file:/home/EntDevOps/.m2/repository/org/codehaus/plexus/plexus-utils/3.2.1/plexus-utils-3.2.1.jar
13:26:57  [ERROR] urls[4] = file:/home/EntDevOps/.m2/repository/org/sonarsource/scanner/api/sonar-scanner-api/2.16.2.588/sonar-scanner-api-2.16.2.588.jar
13:26:57  [ERROR] urls[5] = file:/home/EntDevOps/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar
13:26:57  [ERROR] Number of foreign imports: 1
13:26:57  [ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
13:26:57  [ERROR] 
13:26:57  [ERROR] -----------------------------------------------------
13:26:57  [ERROR] -> [Help 1]
13:26:57  [ERROR] 
13:26:57  [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
13:26:57  [ERROR] Re-run Maven using the -X switch to enable full debug logging.
13:26:57  [ERROR] 
13:26:57  [ERROR] For more information about the errors and possible solutions, please read the following articles:
13:26:57  [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException

Hi,

Welcome to the community!

I’m glad to hear you’re working on your upgrade. I see two things here:

You’re aware that you can’t go straight from 7.9.2 to 9.4, right? You can’t upgrade across an LTS, you have to go through it. So, your upgrade path is

7.9.2 → 8.9.8 → 9.4

Once you get to a modern version, you’ll find that the minimum Java version has changed, which is what your analysis error is telling you. Per the docs, Java 8 is no longer supported either for running the server or analysis. You’ll need to install Java 11 or 17 on your build agents for this to work.

 
HTH,
Ann