[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:5.1.0.4751:sonar

Hi,

I’ve SonarQube EE 10.5 with Azure DevOps integration and Apache Maven 3.9.6 installed.

In the Azure pipeline I’ve the following tasks:

  - task: SonarQubePrepare@7
    displayName: 'Prepare sonar properties'
    inputs:
      # Service Connection ADO > SonarQube Server
      SonarQube: '$(SonarQubeSC)' 
      scannerMode: 'other' # Maven scanner
      extraProperties: |
        # Properties that will be passed to the scanner   
        sonar.projectKey=$(sqProjectKey)
        sonar.projectName=$(sqProjectName)
        sonar.projectVersion=$(calcvers.NEW_VERSION)
        sonar.branch.name=$(Build.SourceBranchName) 
        sonar.sources=$(GIT_SOURCES_PATH)/${{ parameters.sqSonarSources}}
        sonar.tests=$(GIT_SOURCES_PATH)/${{ parameters.sqSonarTests }}
        sonar.scm.revision=$(Build.SourceVersion)
        sonar.analysis.buildNumber=$(Build.BuildNumber)
        sonar.links.ci='BUILD ADO $(Build.BuildId)'
        sonar.links.scm='$(Build.Repository.Uri)'
        sonar.exclusions=${{ parameters.sqSonarExclusions }}
  

  - task: Maven@4
    displayName: 'mvn package'
    condition: succeeded()
    inputs:
      mavenPomFile: '$(GIT_SOURCES_PATH)/pom.xml'
      goals: '${{ parameters.cmdMavenGoal }}'
      options: '-s ${{ parameters.PathSettingsFile }}'
      publishJUnitResults: true
      testResultsFiles: '**/surefire-reports/TEST-*.xml'
      codeCoverageToolOption: 'JaCoCo'
      javaHomeOption: 'Path'
      jdkDirectory: '$(PathJDKProject)'
      #   default maven installed on Agent DevOps (capabilities)
      mavenVersionOption: 'Default' 
      mavenSetM2Home: false
      mavenAuthenticateFeed: false
      effectivePomSkip: false
      sonarQubeRunAnalysis: false
      isJacocoCoverageReportXML: true

  - task: Maven@4
    displayName: 'sonar mvn scan'
    condition: succeeded()
    inputs:
      mavenPomFile: '$(GIT_SOURCES_PATH)/pom.xml'
      publishJUnitResults: false
      options: '-DskipTests=true'
      sonarQubeRunAnalysis: true
      sqMavenPluginVersionChoice: 'latest'

I’m getting this error

Logs of Scanner failed:

2025-04-03T14:19:39.3983087Z ##[section]Starting: [SonarAnalysis] Maven-Scanner sonar
2025-04-03T14:19:39.3999568Z ==============================================================================
2025-04-03T14:19:39.3999956Z Task         : Maven
2025-04-03T14:19:39.4000163Z Description  : Build, test, and deploy with Apache Maven
2025-04-03T14:19:39.4000552Z Version      : 4.249.6
2025-04-03T14:19:39.4000764Z Author       : Microsoft Corporation
2025-04-03T14:19:39.4000978Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/maven
2025-04-03T14:19:39.4001276Z ==============================================================================
2025-04-03T14:19:40.6187040Z [command]/opt/maven/apache-maven-3.9.6/bin/mvn -version
2025-04-03T14:19:41.0738576Z Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)
2025-04-03T14:19:41.0740003Z Maven home: /opt/maven/apache-maven-3.9.6
2025-04-03T14:19:41.0745360Z Java version: 11.0.0.2, vendor: Oracle Corporation, runtime: /opt/openjdk/jdk-11.0.0.2
2025-04-03T14:19:41.0746243Z Default locale: en, platform encoding: UTF-8
2025-04-03T14:19:41.0746979Z OS name: "linux", version: "6.8.0-1021-azure", arch: "amd64", family: "unix"
2025-04-03T14:19:41.0948246Z 
2025-04-03T14:19:41.1018582Z [command]/opt/maven/apache-maven-3.9.6/bin/mvn -f /home/user/myagent2/_work/41/s/sources/hubmisure-users/pom.xml -DskipTests=true package org.sonarsource.scanner.maven:sonar-maven-plugin:RELEASE:sonar
2025-04-03T14:19:44.2404660Z [INFO] Scanning for projects...
2025-04-03T14:19:44.8275925Z [WARNING] 
2025-04-03T14:19:44.8282307Z [WARNING] Some problems were encountered while building the effective model for com.sample.project:users:jar:0.0.1-SNAPSHOT
2025-04-03T14:19:44.8283768Z [WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.jacoco:jacoco-maven-plugin @ line 90, column 15
2025-04-03T14:19:44.8284472Z [WARNING] 
2025-04-03T14:19:44.8285077Z [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
2025-04-03T14:19:44.8285655Z [WARNING] 
2025-04-03T14:19:44.8286235Z [WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
2025-04-03T14:19:44.8286784Z [WARNING] 
2025-04-03T14:19:44.9724154Z [INFO] 
2025-04-03T14:19:44.9726149Z [INFO] -------------------< com.sample.project:users >--------------------
2025-04-03T14:19:44.9727433Z [INFO] Building demo 0.0.1-SNAPSHOT
2025-04-03T14:19:44.9728267Z [INFO]   from pom.xml
2025-04-03T14:19:44.9728991Z [INFO] --------------------------------[ jar ]---------------------------------
2025-04-03T14:19:46.1576203Z [INFO] 
2025-04-03T14:19:46.1604816Z [INFO] --- jacoco:0.8.11:prepare-agent (prepare-agent) @ users ---
2025-04-03T14:19:46.4407784Z [INFO] argLine set to -javaagent:/home/user/.m2/org/jacoco/org.jacoco.agent/0.8.11/org.jacoco.agent-0.8.11-runtime.jar=destfile=/home/user/myagent2/_work/41/s/sources/hubmisure-users/target/jacoco.exec
2025-04-03T14:19:46.4416630Z [INFO] 
2025-04-03T14:19:46.4422002Z [INFO] --- jacoco:0.8.11:prepare-agent (default-prepare-agent-vsts) @ users ---
2025-04-03T14:19:46.4507095Z [INFO] argLine set to -javaagent:/home/user/.m2/org/jacoco/org.jacoco.agent/0.8.11/org.jacoco.agent-0.8.11-runtime.jar=destfile=/home/user/myagent2/_work/41/s/sources/hubmisure-users/target/jacoco.exec,includes=**/*
2025-04-03T14:19:46.4508449Z [INFO] 
2025-04-03T14:19:46.4510916Z [INFO] --- resources:3.2.0:resources (default-resources) @ users ---
2025-04-03T14:19:46.7803504Z [INFO] Using 'UTF-8' encoding to copy filtered resources.
2025-04-03T14:19:46.7805617Z [INFO] Using 'UTF-8' encoding to copy filtered properties files.
2025-04-03T14:19:46.7852480Z [INFO] Copying 1 resource
2025-04-03T14:19:46.8284166Z [INFO] Copying 0 resource
2025-04-03T14:19:46.8284840Z [INFO] 
2025-04-03T14:19:46.8301979Z [INFO] --- compiler:3.8.1:compile (default-compile) @ users ---
2025-04-03T14:19:47.3026015Z [INFO] Nothing to compile - all classes are up to date
2025-04-03T14:19:47.3027285Z [INFO] 
2025-04-03T14:19:47.3027958Z [INFO] --- resources:3.2.0:testResources (default-testResources) @ users ---
2025-04-03T14:19:47.3117458Z [INFO] Using 'UTF-8' encoding to copy filtered resources.
2025-04-03T14:19:47.3119087Z [INFO] Using 'UTF-8' encoding to copy filtered properties files.
2025-04-03T14:19:47.3124452Z [INFO] skip non existing resourceDirectory /home/user/myagent2/_work/41/s/sources/hubmisure-users/src/test/resources
2025-04-03T14:19:47.3125036Z [INFO] 
2025-04-03T14:19:47.3125722Z [INFO] --- compiler:3.8.1:testCompile (default-testCompile) @ users ---
2025-04-03T14:19:47.3268393Z [INFO] Nothing to compile - all classes are up to date
2025-04-03T14:19:47.3284602Z [INFO] 
2025-04-03T14:19:47.3300139Z [INFO] --- surefire:2.22.2:test (default-test) @ users ---
2025-04-03T14:19:47.6257685Z [INFO] Tests are skipped.
2025-04-03T14:19:47.6283284Z [INFO] 
2025-04-03T14:19:47.6284465Z [INFO] --- jacoco:0.8.11:report (report) @ users ---
2025-04-03T14:19:47.6483648Z [INFO] Loading execution data file /home/user/myagent2/_work/41/s/sources/hubmisure-users/target/jacoco.exec
2025-04-03T14:19:47.8798124Z [INFO] Analyzed bundle 'demo' with 14 classes
2025-04-03T14:19:48.1346431Z [INFO] 
2025-04-03T14:19:48.1348429Z [INFO] --- jacoco:0.8.11:report (default-report-vsts) @ users ---
2025-04-03T14:19:48.1402650Z [INFO] Loading execution data file /home/user/myagent2/_work/41/s/sources/hubmisure-users/target/jacoco.exec
2025-04-03T14:19:48.2063542Z [INFO] Analyzed bundle 'demo' with 14 classes
2025-04-03T14:19:48.3610774Z [INFO] 
2025-04-03T14:19:48.3612109Z [INFO] --- jar:3.2.2:jar (default-jar) @ users ---
2025-04-03T14:19:48.8060977Z [INFO] 
2025-04-03T14:19:48.8071787Z [INFO] --- spring-boot:2.6.6:repackage (repackage) @ users ---
2025-04-03T14:19:49.3486016Z [INFO] Replacing main artifact with repackaged archive
2025-04-03T14:19:49.3519950Z [INFO] 
2025-04-03T14:19:49.3521843Z [INFO] -------------------< com.sample.project:users >--------------------
2025-04-03T14:19:49.3523249Z [INFO] Building demo 0.0.1-SNAPSHOT
2025-04-03T14:19:49.3525308Z [INFO]   from pom.xml
2025-04-03T14:19:49.3526319Z [INFO] --------------------------------[ jar ]---------------------------------
2025-04-03T14:19:49.4320608Z [INFO] 
2025-04-03T14:19:49.4332630Z [INFO] --- sonar:5.1.0.4751:sonar (default-cli) @ users ---
2025-04-03T14:19:49.7142470Z [WARNING] Using RELEASE instead of an explicit plugin version may introduce breaking analysis changes at an unwanted time. It is highly recommended to use an explicit version, e.g. 'org.sonarsource.scanner.maven:sonar-maven-plugin:5.1.0.4751'.
2025-04-03T14:19:49.9046984Z [INFO] Java 11.0.0.2 Oracle Corporation (64-bit)
2025-04-03T14:19:49.9065171Z [INFO] Linux 6.8.0-1021-azure (amd64)
2025-04-03T14:19:49.9077344Z [INFO] MAVEN_OPTS= -Xmx1024m
2025-04-03T14:19:49.9833092Z [INFO] User cache: /home/user/.sonar/cache
2025-04-03T14:19:52.6389058Z [INFO] Communicating with SonarQube Server 10.5.1.90531
2025-04-03T14:19:52.7726420Z [INFO] ------------------------------------------------------------------------
2025-04-03T14:19:52.7727270Z [INFO] BUILD FAILURE
2025-04-03T14:19:52.7728009Z [INFO] ------------------------------------------------------------------------
2025-04-03T14:19:52.7728569Z [INFO] Total time:  8.589 s
2025-04-03T14:19:52.7792132Z [INFO] Finished at: 2025-04-03T14:19:52Z
2025-04-03T14:19:52.7793293Z [INFO] ------------------------------------------------------------------------
2025-04-03T14:19:52.7795997Z [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:5.1.0.4751:sonar (default-cli) on project users: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:5.1.0.4751:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:5.1.0.4751:sonar: 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
2025-04-03T14:19:52.7798915Z [ERROR] -----------------------------------------------------
2025-04-03T14:19:52.7799801Z [ERROR] realm =    plugin>org.sonarsource.scanner.maven:sonar-maven-plugin:RELEASE
2025-04-03T14:19:52.7800703Z [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
2025-04-03T14:19:52.7801863Z [ERROR] urls[0] = file:/home/user/.m2/org/sonarsource/scanner/maven/sonar-maven-plugin/5.1.0.4751/sonar-maven-plugin-5.1.0.4751.jar
2025-04-03T14:19:52.7803142Z [ERROR] urls[1] = file:/home/user/.m2/org/codehaus/plexus/plexus-sec-dispatcher/2.0/plexus-sec-dispatcher-2.0.jar
2025-04-03T14:19:52.7804260Z [ERROR] urls[2] = file:/home/user/.m2/org/codehaus/plexus/plexus-utils/3.4.1/plexus-utils-3.4.1.jar
2025-04-03T14:19:52.7805305Z [ERROR] urls[3] = file:/home/user/.m2/org/codehaus/plexus/plexus-cipher/2.0/plexus-cipher-2.0.jar
2025-04-03T14:19:52.7806610Z [ERROR] urls[4] = file:/home/user/.m2/org/sonarsource/scanner/lib/sonar-scanner-java-library/3.3.1.450/sonar-scanner-java-library-3.3.1.450.jar
2025-04-03T14:19:52.7807749Z [ERROR] urls[5] = file:/home/user/.m2/com/squareup/okhttp3/okhttp/4.12.0/okhttp-4.12.0.jar
2025-04-03T14:19:52.7808737Z [ERROR] urls[6] = file:/home/user/.m2/com/squareup/okio/okio/3.6.0/okio-3.6.0.jar
2025-04-03T14:19:52.7809684Z [ERROR] urls[7] = file:/home/user/.m2/com/squareup/okio/okio-jvm/3.6.0/okio-jvm-3.6.0.jar
2025-04-03T14:19:52.7840994Z [ERROR] urls[8] = file:/home/user/.m2/org/jetbrains/kotlin/kotlin-stdlib-common/1.9.10/kotlin-stdlib-common-1.9.10.jar
2025-04-03T14:19:52.7842402Z [ERROR] urls[9] = file:/home/user/.m2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.8.21/kotlin-stdlib-jdk8-1.8.21.jar
2025-04-03T14:19:52.7843458Z [ERROR] urls[10] = file:/home/user/.m2/org/jetbrains/kotlin/kotlin-stdlib/1.8.21/kotlin-stdlib-1.8.21.jar
2025-04-03T14:19:52.7844355Z [ERROR] urls[11] = file:/home/user/.m2/org/jetbrains/annotations/13.0/annotations-13.0.jar
2025-04-03T14:19:52.7845375Z [ERROR] urls[12] = file:/home/user/.m2/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.8.21/kotlin-stdlib-jdk7-1.8.21.jar
2025-04-03T14:19:52.7846586Z [ERROR] urls[13] = file:/home/user/.m2/com/squareup/okhttp3/okhttp-urlconnection/4.12.0/okhttp-urlconnection-4.12.0.jar
2025-04-03T14:19:52.7847759Z [ERROR] urls[14] = file:/home/user/.m2/com/squareup/okhttp3/logging-interceptor/4.12.0/logging-interceptor-4.12.0.jar
2025-04-03T14:19:52.7848667Z [ERROR] urls[15] = file:/home/user/.m2/com/google/code/gson/gson/2.11.0/gson-2.11.0.jar
2025-04-03T14:19:52.7849678Z [ERROR] urls[16] = file:/home/user/.m2/com/google/errorprone/error_prone_annotations/2.27.0/error_prone_annotations-2.27.0.jar
2025-04-03T14:19:52.7850968Z [ERROR] urls[17] = file:/home/user/.m2/org/apache/commons/commons-compress/1.27.1/commons-compress-1.27.1.jar
2025-04-03T14:19:52.7851981Z [ERROR] urls[18] = file:/home/user/.m2/commons-codec/commons-codec/1.17.1/commons-codec-1.17.1.jar
2025-04-03T14:19:52.7852893Z [ERROR] urls[19] = file:/home/user/.m2/commons-io/commons-io/2.16.1/commons-io-2.16.1.jar
2025-04-03T14:19:52.7854100Z [ERROR] urls[20] = file:/home/user/.m2/org/sonarsource/scanner/lib/sonar-scanner-java-library-batch-interface/3.3.1.450/sonar-scanner-java-library-batch-interface-3.3.1.450.jar
2025-04-03T14:19:52.7855204Z [ERROR] urls[21] = file:/home/user/.m2/io/github/hakky54/sslcontext-kickstart/8.3.6/sslcontext-kickstart-8.3.6.jar
2025-04-03T14:19:52.7856250Z [ERROR] urls[22] = file:/home/user/.m2/org/bouncycastle/bcprov-jdk18on/1.78.1/bcprov-jdk18on-1.78.1.jar
2025-04-03T14:19:52.7857278Z [ERROR] urls[23] = file:/home/user/.m2/org/apache/commons/commons-lang3/3.14.0/commons-lang3-3.14.0.jar
2025-04-03T14:19:52.7858767Z [ERROR] Number of foreign imports: 1
2025-04-03T14:19:52.7859285Z [ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
2025-04-03T14:19:52.7859757Z [ERROR] 
2025-04-03T14:19:52.7880903Z [ERROR] -----------------------------------------------------
2025-04-03T14:19:52.7881781Z [ERROR] 
2025-04-03T14:19:52.7882461Z [ERROR] -> [Help 1]
2025-04-03T14:19:52.7882854Z [ERROR] 
2025-04-03T14:19:52.7883608Z [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
2025-04-03T14:19:52.7884430Z [ERROR] Re-run Maven using the -X switch to enable full debug logging.
2025-04-03T14:19:52.7884916Z [ERROR] 
2025-04-03T14:19:52.7885477Z [ERROR] For more information about the errors and possible solutions, please read the following articles:
2025-04-03T14:19:52.7886184Z [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
2025-04-03T14:19:52.8262803Z 
2025-04-03T14:19:52.8287537Z The process '/opt/maven/apache-maven-3.9.6/bin/mvn' failed with exit code 1
2025-04-03T14:19:52.8292241Z Could not retrieve code analysis results - Maven run failed.
2025-04-03T14:19:52.8301557Z ##[error]Build failed.
2025-04-03T14:19:52.8478396Z ##[section]Finishing: [SonarAnalysis] Maven-Scanner sonar

If I understand correctly it is a compatibility issue with the maven plugin for SonarQube. Could you confirm?
Suggestions for resolution?

Assuming that I cannot specify the version of the sonar plugin inside the pom.xml, how can I make the Maven@4 task use a specific version and not the “latest”?

Thanks, Manuel

Hi,

Here you go:

You’re running the task with Java 11:

You’ll need to bump that up to 17.

 
HTH,
Ann