Search code examples
javamavenazure-devopsazure-pipelinessonarcloud

Error integrating Azure DevOps Classic Pipeline with SonarCloud: Java version issue


I am encountering an issue while attempting to integrate an Azure DevOps classic pipeline with SonarCloud for a Java project that utilizes Maven for package management.

I initially tested this SonarCloud integration using Jenkins, where it appeared to be a Java version issue. However, even after upgrading the Java version on the server and updating certain SonarQube plugins, the error persists. Consequently, I decided to switch to Azure DevOps, but I am still encountering the same issue.

[INFO] Reactor Summary:
[INFO]
[INFO] petclinic_api 0.0.1-SNAPSHOT ....................... FAILURE [  5.253 s]
[INFO] dto 0.0.1-SNAPSHOT ................................. SUCCESS [  9.515 s]
[INFO] exception 0.0.1-SNAPSHOT ........................... SUCCESS [  0.200 s]
[INFO] petclinic-service-internal 2018.9-RELEASE .......... SUCCESS [ 39.459 s]
[INFO] petclinic-service-external 2018.9-RELEASE .......... SUCCESS [  5.430 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.11.0.3922:sonar
(default-cli) on project my-project-name: The plugin [python] does not support Java 11.0.22: 
org/sonar/plugins/python/PythonPlugin 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 -> [Help 1]

Below are the main configurations in the pipeline:

Classic Pipeline Name: Maven with SonarCloud
Agent: Azure Pipelines (ubuntu-latest)
Scanner: Use standalone scanner
Mode: Manual provide configuration
Maven goals and options: package  -e  -Dmaven.test.skip=true
Code analysis: Run SonarQube or SonarCloud analysis (use latest version)
JDK version: Default

main pom.yaml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.petclinic</groupId>
   <artifactId>petclinic_service</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <packaging>pom</packaging>
   <name>petclinic_api</name>
   <url>http://maven.apache.org</url>
   <modules>
      <module>dto</module>
      <module>exception</module>
      <module>petclinic-saas</module>
      <module>petclinic-api</module>
   </modules>
</project>

Following steps have been taken:

  • I upgraded the Java version on the server and updated certain SonarQube plugins. I was expecting these changes to resolve the compatibility issue with SonarCloud.
  • Upgraded the Jenkins version as well but no change in the response.
  • Changed the JDK version to 17, then I received the following error
[INFO] Reactor Summary:
[INFO]
[INFO] petclinic_api 0.0.1-SNAPSHOT ....................... SUCCESS [  0.005 s]
[INFO] dto 0.0.1-SNAPSHOT ................................. SUCCESS [  9.315 s]
[INFO] exception 0.0.1-SNAPSHOT ........................... SUCCESS [  0.219 s]
[INFO] petclinic-service-internal 2018.9-RELEASE .......... FAILURE [ 18.852 s]
[INFO] petclinic-service-external 2018.9-RELEASE .......... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile)
on project petclinic-saas: Fatal error compiling: java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor
(in unnamed module @0x1667a6f7) cannot access class
com.sun.tools.javac.processing.JavacProcessingEnvironment (in module jdk.compiler) because module jdk.compiler does not export
com.sun.tools.javac.processing to unnamed module @0x1667a6f7 -> [Help 1]

Could someone provide guidance or assistance in resolving this issue? Any insights or suggestions would be greatly appreciated.


Solution

  • Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.11.0.3922:sonar (default-cli) on project my-project-name: The plugin [python] does not support Java 11.0.22

    For this issue, this means that you need to upgrade your java version.

    Fatal error compiling: java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module @0x1667a6f7) cannot access class..

    After you upgrade Java version to 17, the cause of this issue is that the dependency org.projectlombok version is not compatible with Java version.

    I can reproduce the same issue when using version 1.18.10.

    enter image description here

    To solve this issue, you need to upgrade the version of dependency org.projectlombok(e.g. version 1.18.28).

    For example:

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.28</version>
            <scope>provided</scope>
        </dependency>
    

    Result:

    enter image description here

    For more detailed info, you can refer to this ticket: Make Lombok compatible with JDK