Support Java 17 in the Sonar Maven Plugin


Currently, when running sonar analysis using sonar-maven-plugin in maven 3.8.3 and JDK 17 (AWS Corretto) we get the following error

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin: (default-cli) on project exchange-service: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin: failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin: java.lang.ExceptionInInitializerError: null
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.sonarsource.scanner.maven:sonar-maven-plugin:
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/Users/meliad2/.m2/repository/org/sonarsource/scanner/maven/sonar-maven-plugin/
[ERROR] urls[1] = file:/Users/meliad2/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar
[ERROR] urls[2] = file:/Users/meliad2/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[3] = file:/Users/meliad2/.m2/repository/org/codehaus/plexus/plexus-utils/3.2.1/plexus-utils-3.2.1.jar
[ERROR] urls[4] = file:/Users/meliad2/.m2/repository/org/sonarsource/scanner/api/sonar-scanner-api/
[ERROR] urls[5] = file:/Users/meliad2/.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]]
[ERROR] -----------------------------------------------------
[ERROR] : java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int, throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @1ce6a9bd

Would it be possible to support Java 17 in the sonar maven plugin?


Hi @davidmelia ,

I’ve tried to analyze a project locally with mvn 3.8.3, openjdk version "17" 2021-09-14, sonar-maven-plugin, and SonarQube 9.1 without any issue. Could you try locally and give a bit more details to help reproduce the issue?

@mpaladin and in the current LTS version ? Do you plan to include the Java17 support ? If not when will be the next LTS version with Java17 support ?
Thanks in advance for your feedbacks :wink:

Thanks @mpaladin

I can confirm that this is a problem only when using SonarQube Server 7.9.1 and after upgrading to SonarQube Server 9.1 the problem is solved.

I didn’t realise there was a relationship from the server to the maven plugin which could cause this type of issue.

Thanks for your help :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.