I have followed the guide on how-to upgrade to JDK 11 when doing the SonarQube Analysis as JDK 1.8 is deprecated:
https://docs.sonarqube.org/latest/analysis/analysis-with-java-11/
Still we get an error when we run the analysis:
[Pipeline] withSonarQubeEnv
[Pipeline] sh
09:42:18 + export JAVA_HOME=/usr/data/jdk/jdk11
09:42:18 + JAVA_HOME=/usr/data/jdk/jdk11
09:42:18 + export PATH=/usr/data/jenkins2/tools/hudson.tasks.Maven_MavenInstallation/Maven_3/bin:/usr/data/jdk/jdk11/bin:/usr/local/bin:/usr/bin
09:42:18 + PATH=/usr/data/jenkins2/tools/hudson.tasks.Maven_MavenInstallation/Maven_3/bin:/usr/data/jdk/jdk11/bin:/usr/local/bin:/usr/bin
09:42:18 + export 'MAVEN_OPTS=-Xmx1024m -XX:+CMSClassUnloadingEnabled'
09:42:18 + MAVEN_OPTS='-Xmx1024m -XX:+CMSClassUnloadingEnabled'
09:42:18 + java -version
09:42:18 java version "11.0.11" 2021-04-20 LTS
09:42:18 Java(TM) SE Runtime Environment 18.9 (build 11.0.11+9-LTS-194)
09:42:18 Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.11+9-LTS-194, mixed mode)
09:42:18 + mvn -version
09:42:18 Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
09:42:18 Maven home: /usr/data/jenkins2/tools/hudson.tasks.Maven_MavenInstallation/Maven_3
09:42:18 Java version: 11.0.11, vendor: Oracle Corporation, runtime: /usr/data/jdk/jdk-11.0.11
09:42:18 Default locale: en_US, platform encoding: ANSI_X3.4-1968
09:42:18 OS name: "linux", version: "3.10.0-1160.25.1.el7.x86_64", arch: "amd64", family: "unix"
09:42:18 + mvn --batch-mode sonar:sonar -Dsonar.projectKey=rs-mortgage-agreement-documents -Dsonar.projectName=rs-mortgage-agreement-documents -Dsonar.branch.name=feature/CODE-917-upgrade-to-jdk-11-when-doing-sonarqube-analysis -Dsun.jnu.encoding=UTF-8 -Dsonar.dependencyCheck.htmlReportPath=/usr/data/jenkins2/workspace/11-when-doing-sonarqube-analysis-2/target/dependency-check-report.html -Dsonar.dependencyCheck.jsonReportPath=/usr/data/jenkins2/workspace/11-when-doing-sonarqube-analysis-2/target/dependency-check-report.json -Dsonar.dependencyCheck.securityHotspot=true --settings /usr/data/jenkins2/workspace/11-when-doing-sonarqube-analysis-2-tmp/config16015946705888257724tmp
09:42:17 [jdk_11] $ sh -e /usr/data/jenkins2/tools/hudson.model.JDK/jdk_11/hudson7446857102831656484.sh
09:42:19 [INFO] Scanning for projects...
09:42:19 [INFO] ------------------------------------------------------------------------
09:42:19 [INFO] Reactor Build Order:
09:42:19 [INFO]
09:42:19 [INFO] agreement-documents [pom]
09:42:19 [INFO] Agreement Documents Resource [jar]
09:42:19 [INFO] Agreement Documents Services [war]
09:42:19 [INFO] Agreement Documents Stub Services [ear]
09:42:20 [INFO] Downloading from xx: http://xx/deployable-maven-plugin/maven-metadata.xml
09:42:20 [INFO] Downloaded from xx: http://xx/deployable-maven-plugin/maven-metadata.xml (2.1 kB at 20 kB/s)
09:42:20 [INFO] Downloading from xx: http://xx/org/apache/maven/plugins/maven-metadata.xml
09:42:20 [INFO] Downloading from xx: http://xx/org/codehaus/mojo/maven-metadata.xml
09:42:20 [INFO] Downloaded from xx: http://xx/org/apache/maven/plugins/maven-metadata.xml (15 kB at 382 kB/s)
09:42:24 [INFO] Downloaded from xx: http://xx/org/codehaus/mojo/maven-metadata.xml (21 kB at 5.0 kB/s)
09:42:24 [INFO] Downloading from xx: http://xx/org/codehaus/mojo/sonar-maven-plugin/maven-metadata.xml
09:42:24 [INFO] Downloaded from xx: http://xx/org/codehaus/mojo/sonar-maven-plugin/maven-metadata.xml (1.3 kB at 46 kB/s)
09:42:24 [INFO]
09:42:24 [INFO] --------< xx.mortgage:rs-mortgage-agreement-documents >--------
09:42:24 [INFO] Building REST agreement-documents 1.0.46-SNAPSHOT [1/4]
09:42:24 [INFO] --------------------------------[ pom ]---------------------------------
09:42:25 [INFO] ------------------------------------------------------------------------
09:42:25 [INFO] Reactor Summary for REST agreement-documents 1.0.46-SNAPSHOT:
09:42:25 [INFO]
09:42:25 [INFO] REST agreement-documents .................. FAILURE [ 0.582 s]
09:42:25 [INFO] Agreement Documents Resource ....................... SKIPPED
09:42:25 [INFO] Agreement Documents Services ....................... SKIPPED
09:42:25 [INFO] Agreement Documents Stub Services .................. SKIPPED
09:42:25 [INFO] ------------------------------------------------------------------------
09:42:25 [INFO] BUILD FAILURE
09:42:25 [INFO] ------------------------------------------------------------------------
09:42:25 [INFO] Total time: 5.830 s
09:42:25 [INFO] Finished at: 2021-05-27T09:42:25+02:00
09:42:25 [INFO] ------------------------------------------------------------------------
09:42:25 [ERROR] Failed to execute goal on project agreement-documents: Could not resolve dependencies for project xx.mortgage:agreement-documents:jar:1.0.46-SNAPSHOT: Could not find artifact com.sun:tools:jar:8.0 at specified path /usr/data/jdk/jdk-11.0.11/../lib/tools.jar -> [Help 1]
09:42:25 [ERROR]
09:42:25 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
09:42:25 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
09:42:25 [ERROR]
09:42:25 [ERROR] For more information about the errors and possible solutions, please read the following articles:
09:42:25 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
09:42:25 [ERROR]
09:42:25 [ERROR] After correcting the problems, you can resume the build with the command
09:42:25 [ERROR] mvn <args> -rf :agreement-documents
[Pipeline] echo
09:42:25 ExitCode for maven process: 1
[Pipeline] }
09:42:25 WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeed?
[Pipeline] // withSonarQubeEnv
We are running SonarQube Enterprise Edition 8.9 LTS
We compile the project with JDK 1.8 and in the same pipeline we run sonar:sonar with JDK 11 as documented by SonarSource - still we run into this.
Anybody seen this ?