[Azure Pipelines] Scanner suddenly requires a newer Java version

Must-share information (formatted with Markdown):

  • which versions are you using: SonarQubeAnalyzer@5
  • how is SonarQube deployed: not sure
  • what are you trying to achieve: Run the scanner in Azure Pipelines
  • what have you tried so far to achieve this:
# in azure-pipelines.yml
pool:
  vmImage: "ubuntu-22.04"
steps:
# ...
- task: SonarQubeAnalyze@5

This configuration used to work, today it started crashing without a change to my configuration.

Log:

Author       : sonarsource
Help         : Version: 5.19.1. This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

[More Information](http://redirect.sonarsource.com/doc/install-configure-scanner-tfs-ts.html)
==============================================================================
##[warning]This task was configured to use Java 11, but the SonarQube server v10.4.1 does not support it. Ignoring the configuration and using JAVA_HOME instead. Specify jdkversion in your task definition to use Java 17 to remove this warning.
/usr/bin/dotnet /home/vsts/work/_tasks/SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157/5.19.1/dotnet-sonar-scanner-msbuild/SonarScanner.MSBuild.dll end
SonarScanner for MSBuild 5.15
Using the .NET Core version of the Scanner for MSBuild
Post-processing started.
Calling the SonarScanner CLI...
INFO: Scanner configuration file: /home/vsts/work/_tasks/SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157/5.19.1/dotnet-sonar-scanner-msbuild/sonar-scanner-4.8.1.3023/conf/sonar-scanner.properties
INFO: Project root configuration file: /home/vsts/work/1/.sonarqube/out/sonar-project.properties
INFO: SonarScanner 4.8.1.3023
INFO: Java 11.0.22 Eclipse Adoptium (64-bit)
INFO: Linux 6.5.0-1016-azure amd64
INFO: User cache: /home/vsts/.sonar/cache
INFO: Analyzing on SonarQube server 10.4.1.88267
INFO: Default locale: "en", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 3.688s
INFO: Final Memory: 4M/17M
INFO: ------------------------------------------------------------------------
##[error]ERROR: Error during SonarScanner execution
ERROR: Error during SonarScanner execution
##[error]java.lang.UnsupportedClassVersionError: org/sonar/batch/bootstrapper/EnvironmentInformation has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0
java.lang.UnsupportedClassVersionError: org/sonar/batch/bootstrapper/EnvironmentInformation has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0
##[error]at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
##[error]at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1022)
	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
	at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:555)
	at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:458)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1022)
	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
	at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:555)
	at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:458)
##[error]at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:452)
	at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:452)
##[error]at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:451)
	at org.sonarsource.scanner.api.internal.IsolatedClassloader.loadClass(IsolatedClassloader.java:82)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:527)
	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 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)

I would suggest that if JAVA_HOME_11_X64 is not supported (the default of the VSTS task) then the fallback should be JAVA_HOME_17_X64, not JAVA_HOME, which I believe is JDK 8 on a cloud-hosted Ubuntu agent. (see runner-images/images/ubuntu/Ubuntu2204-Readme.md at main · actions/runner-images · GitHub)

1 Like

Hello @sliekens , welcome to our community!

I responded on your PR and gave a bit more insights, the bottom line is that we can not just update the default jdk from 11 to 17 or we would break the SQ LTS users that do not have JDK17 installed on their machine

I would suggest that if JAVA_HOME_11_X64 is not supported (the default of the VSTS task) then the fallback should be JAVA_HOME_17_X64, not JAVA_HOME

We will change the default jdk version in the next major version of the extension that will be released as part of this ticket VSTS-356. Feel free to track the ticket to see when it gets released.

Hope this helps

1 Like