Azuredevops gradle sonarqube task scanner or analyze not working with jdk 17

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)

This is running Gradle plugin with sonarqube set to true on ADO (Azure Devops)

UI: SonarQube Version 6.7.1 (build 35068) - LGPL v3 - Community
JVM: 17.0.4 (Private Build 17.0.4+8-Ubuntu-118.04)
Gradle 7.4.1
id “org.sonarqube” version ‘3.4.0.2513’

INFO: SonarScanner 4.7.0.2747
INFO: Java 11.0.16 Ubuntu (64-bit)
INFO: Linux 5.4.0-1086-azure amd64

> Task :sonarqube
Unable to create symbol table for : 'build/generated-src/xxxxx.java'
java.lang.IllegalArgumentException: Unsupported class file major version 61
	at org.objectweb.asm.ClassReader.<init>(ClassReader.java:195)
	at org.objectweb.asm.ClassReader.<init>(ClassReader.java:176)
	at org.objectweb.asm.ClassReader.<init>(ClassReader.java:162)
	at org.sonar.java.resolve.BytecodeCompleter.loadClass(BytecodeCompleter.java:244)
	at org.sonar.java.resolve.Symbols.<init>(Symbols.java:176)
	at org.sonar.java.resolve.SemanticModel.createFor(SemanticModel.java:60)
	at org.sonar.java.model.VisitorsBridge.visitFile(VisitorsBridge.java:122)
	at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:90)
	at org.sonar.java.ast.JavaAstScanner.scan(JavaAstScanner.java:67)
	at org.sonar.java.JavaSquid.scanSources(JavaSquid.java:114)
	at org.sonar.java.JavaSquid.scan(JavaSquid.java:108)
	at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:88)
	at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)
	at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:88)
	at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:82)
	at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:68)
	at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:88)
  • what are you trying to achieve
  • what have you tried so far to achieve this

setting for Prepare has been

- task: SonarQubePrepare@5
  inputs:
	SonarQube: 'sonarConnection'
	scannerMode: 'Other'
	extraProperties: |
	  sonar.verbose=True
	  sonar.projectKey=project_key
	  sonar.projectName=project_name
	  sonar.projectVersion=v1.0
	  sonar.exclusions="**/generated/**,**/exception/**"

jdk-17 is used by gradle project for its build.

and the gradle build with sonarqube enabled is
    - task: Gradle@2
      inputs:
        gradleWrapperFile: 'gradlew'
        tasks: 'build'
        publishJUnitResults: false
        javaHomeOption: 'Path'
        jdkDirectory: '/usr/lib/jvm/java-17-openjdk-amd64/'
        gradleOptions: '-Xmx3072m'
        sonarQubeRunAnalysis: true
        sqGradlePluginVersionChoice: 'build'
        spotBugsAnalysis: false
      displayName: Gradle Build & Publish Test Results	  

The build part goes fine.
but when the sonarqube task is run, it throws error

Task :sonarqube
Unable to create symbol table for : ‘build/generated-src/xxxxx.java’
java.lang.IllegalArgumentException: Unsupported class file major version 61
at org.objectweb.asm.ClassReader.(ClassReader.java:195)
at org.objectweb.asm.ClassReader.(ClassReader.java:176)

As this is Gradle , I cannot run the Analyzer part separately (- task: SonarQubeAnalyze@5)

I even tried to set the below in SonarQubePrepare - extaProperties.

	  sonar.java.source=1.17
	  sonar.java.jdkHome=/usr/lib/jvm/java-17-openjdk-amd64

But get the same Error as above.

Please advise.

Note:

sonar.java.jdkHome: Java | SonarQube Docs

sonar.java.source: Java | SonarQube Docs

The references above say one doesn’t need to set these if one is using Maven/Gradle
and since I am using Gradle those really doesn’t need to be set.

Hi,

Your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

6.7.1 → 7.9.6 → 8.9.9 → 9.6 (last step optional)

You may find the Upgrade Guide and the LTS-to-LTS Upgrade Notes helpful. If you have questions about upgrading, feel free to open a new thread for that here.

If your error persists after upgrade, please come back to us.

Thanks for your quick reply.
So you are saying the server version 6.7.1 doesn’t support java-17 version ?
upto what version does it support. ?
Is there any wiki page which list which version of sonarqube server supports what version.

Thanks.

Correct

Java 8

There is not – but you can trust that Java 17 is only supported in the latest supported version of SonarQube (v9.6)