Reputation: 506
I'm trying to integrate SonarQube scanner into a TeamCity build configuration. I have installed the Sonar Runner plugin and set the build step to use scanner version 4.2.0, and run a build with the step enabled. Sonar Runner version is 2020.1-12
provided by JetBrains.
When the build reaches the step, it fails with
ERROR: Error during SonarQube Scanner execution
11:57:05 INFO: Final Memory: 5M/245M
11:57:05 INFO: ------------------------------------------------------------------------
11:57:05 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 52.0
11:57:05 at java.lang.ClassLoader.defineClass1(Native Method)
11:57:05 at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
11:57:05 at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
11:57:05 at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
11:57:05 at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
11:57:05 at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
11:57:05 at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
11:57:05 at java.security.AccessController.doPrivileged(Native Method)
11:57:05 at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
11:57:05 at org.sonarsource.scanner.api.internal.IsolatedClassloader.loadClass(IsolatedClassloader.java:82)
11:57:05 at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
11:57:05 at org.sonarsource.scanner.api.internal.batch.DefaultBatchFactory.createBatch(DefaultBatchFactory.java:32)
11:57:05 at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
11:57:05 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
11:57:05 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
11:57:05 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
11:57:05 at java.lang.reflect.Method.invoke(Method.java:498)
11:57:05 at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
11:57:05 at com.sun.proxy.$Proxy0.execute(Unknown Source)
11:57:05 at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
11:57:05 at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
11:57:05 at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
11:57:05 at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
11:57:05 at org.sonarsource.scanner.cli.Main.main(Main.java:61)
11:57:05 ERROR:
We've checked the TeamCity server, and it's running JRE v23.0.2
java version "23.0.2" 2025-01-21
Java(TM) SE Runtime Environment (build 23.0.2+7-58)
Java HotSpot(TM) 64-Bit Server VM (build 23.0.2+7-58, mixed mode, sharing)
which can run class files up to v67.
What am I missing here?
Upvotes: 0
Views: 19
Reputation: 506
I resolved this by updating the buildAgent.properties
file, adding the line
env.TEAMCITY_JRE=C\:\\Program Files\\Java\\jdk-23
Now in TeamCity, on my SonarRunner step, I see the following
I don't know why adding it to the agent configuration means it shows in the build configuration step, but without the line present, it wasn't working.
Upvotes: 0