- which versions are you using ?
- SonarQube: Version 7.4 (build 18908)
- Scanner: 4.0.0.4121 (sonar-maven-plugin)
- Plugin:
[DEBUG] 11:22:22.425 Plugins:
[DEBUG] 11:22:22.426 * SonarPython 1.10.0.2131 (python)
[DEBUG] 11:22:22.426 * SonarCSS 1.0.2.611 (cssfamily)
[DEBUG] 11:22:22.426 * JaCoCo 1.0.1.143 (jacoco)
[DEBUG] 11:22:22.427 * SonarGo 1.1.0.1612 (go)
[DEBUG] 11:22:22.427 * SonarKotlin 1.2.1.2009 (kotlin)
[DEBUG] 11:22:22.427 * Svn 1.9.0.1295 (scmsvn)
[DEBUG] 11:22:22.428 * SonarJS 5.0.0.6962 (javascript)
[DEBUG] 11:22:22.428 * SonarRuby 1.2.1.2009 (ruby)
[DEBUG] 11:22:22.428 * SonarC# 7.7.0.7192 (csharp)
[DEBUG] 11:22:22.429 * SonarJava 5.8.0.15699 (java)
[DEBUG] 11:22:22.429 * LDAP 2.2.0.608 (ldap)
[DEBUG] 11:22:22.430 * Git 1.6.0.1349 (scmgit)
[DEBUG] 11:22:22.430 * SonarFlex 2.4.0.1222 (flex)
[DEBUG] 11:22:22.430 * SonarXML 1.5.1.1452 (xml)
[DEBUG] 11:22:22.431 * SonarPHP 2.14.0.3569 (php)
[DEBUG] 11:22:22.431 * SonarTS 1.8.0.3332 (typescript)
[DEBUG] 11:22:22.431 * SonarVB 7.7.0.7192 (vbnet)
But only Git, JaCoCo and SonarJava are relevant because I use Java
-
how is SonarQube deployed: Docker, on a extra machine
-
what are you trying to achieve: build and analyze a java project in a jenkins docker pipeline which was running on jdk 11 but should now be running on jdk 21.
-
what have you tried so far to achieve this:
The current jenkins pipeline uses a docker image with jdk 11
FROM eclipse-temurin:11-jdk-alpine`
...
the jenkinsfile itself has two stages for the analysis
stage('Sonar Analysis') {
steps {
script {
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE', message: 'Sonar analysis failed!') {
withSonarQubeEnv('sonar') {
sh './mvnw -Pci -X -Dcheckstyle.skip sonar:sonar -Dsonar.branch=$BRANCH_NAME'
}
}
}
}
}
stage('Quality Gate') {
steps {
timeout(time: 10, unit: 'MINUTES') {
script {
def qg = waitForQualityGate()
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}
}
}
As I already wrote this part work perfectly for java 11. But when I change the jdk to 21
FROM eclipse-temurin:21.0.4_7-jdk-alpine
...
I get the following exception:
[ERROR] 09:26:27.341 Unable to create symbol table for : /home/jenkins/workspace/mybranchname/src/test/java/MyClassTest.java
java.lang.IllegalArgumentException: Unsupported class file major version 65
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:176)
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:158)
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:146)
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:109)
at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:96)
at org.sonar.java.ast.JavaAstScanner.scan(JavaAstScanner.java:68)
at org.sonar.java.JavaSquid.scanTests(JavaSquid.java:122)
at org.sonar.java.JavaSquid.scan(JavaSquid.java:111)
at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:93)
at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:45)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:88)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:62)
at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:74)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:164)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:319)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:314)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:288)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:82)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:131)
at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:71)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at jdk.proxy3/jdk.proxy3.$Proxy25.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.java:89)
at org.sonarsource.scanner.maven.SonarQubeMojo.execute(SonarQubeMojo.java:113)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
As far as I can see is that JavaSquid
is complaining about the byte code version of the jdk21. And I see that JavaSquid
is not listed in the installed plugins but it is in the plugins package. At this point I was wondering whether JavaSquid was complaining about the compiled code or the jvm in which the scanner was executed. It turned out it complains about the jvm in which it was executed. When I changed the jvm of the docker file to
FROM eclipse-temurin:17-jdk-alpine
...
i get the following error
java.lang.IllegalArgumentException: Unsupported class file major version 61
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:176)
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:158)
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:146)
...
To me it looks like the scanner somehow complains about the jvm in which it is executed.
The documentation for every version (8.9 - 10.5) which is online says
SonarQube is able to analyze any kind of Java source files regardless of the version of Java they comply with.
Yes I use an older version which is 7.5 but I would guess that this version is also able to analyze any Java source code.
How can I solve the problem? I don’t know if updating the sonarqube is an option, I have other Java 11 projects which should still be buildable and which will not be migrated to a newer java version.