Sonar 10.5.1.09531 not starting with JDK 21 and getting error

When I try to start the sonarqube version with JDK 21 getting error as below, and when the same is tried with JDK 17 its working fine.

2024.05.08 15:19:58 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory C:\Users\Documents\Softwares\sonarqube-10.5.1.90531\temp
2024.05.08 15:19:58 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on [HTTP: 127.0.0.1:9001, TCP: 127.0.0.1:49891]
2024.05.08 15:19:58 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[ELASTICSEARCH] from [C:\Users\Documents\Softwares\sonarqube-10.5.1.90531\elasticsearch]: C:\Users\Documents\Softwares\jdk-21.0.3\bin\java -Xms4m -Xmx64m -XX:+UseSerialGC -Dcli.name=server -Dcli.script=./bin/elasticsearch -Dcli.libs=lib/tools/server-cli -Des.path.home=C:\Users\Documents\Softwares\sonarqube-10.5.1.90531\elasticsearch -Des.path.conf=C:\Users\Documents\Softwares\sonarqube-10.5.1.90531\temp\conf\es -Des.distribution.type=tar -cp C:\Users\Documents\Softwares\sonarqube-10.5.1.90531\elasticsearch\lib\*;C:\Users\Documents\Softwares\sonarqube-10.5.1.90531\elasticsearch\lib\cli-launcher\* org.elasticsearch.launcher.CliToolLauncher
2024.05.08 15:19:58 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
May 08, 2024 3:20:06 PM sun.util.locale.provider.LocaleProviderAdapter <clinit>
WARNING: COMPAT locale provider will be removed in a future release
2024.05.08 15:20:24 INFO  app[][o.s.a.SchedulerImpl] Process[es] is up
2024.05.08 15:20:24 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[WEB_SERVER] from [C:\Users\Documents\Softwares\sonarqube-10.5.1.90531]: C:\Users\Documents\Softwares\jdk-21.0.3\bin\java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=C:\Users\Documents\Softwares\sonarqube-10.5.1.90531\temp -XX:-OmitStackTraceInFastThrow --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED --add-exports=java.base/jdk.internal.ref=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.management/sun.management=ALL-UNNAMED --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED -Dcom.redhat.fips=false -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Dhttp.nonProxyHosts=localhost|127.*|[::1] -cp ./lib/sonar-application-10.5.1.90531.jar;C:\Users\Documents\Softwares\sonarqube-10.5.1.90531\lib\jdbc\h2\h2-2.2.224.jar org.sonar.server.app.WebServer C:\Users\Documents\Softwares\sonarqube-10.5.1.90531\temp\sq-process5960965584461263725properties
Exception in thread "main" java.lang.UnsupportedOperationException: The Security Manager is deprecated and will be removed in a future release
	at java.base/java.lang.System.setSecurityManager(System.java:430)
	at org.sonar.process.PluginSecurityManager.restrictPlugins(PluginSecurityManager.java:42)
	at org.sonar.server.app.WebSecurityManager.apply(WebSecurityManager.java:47)
	at org.sonar.server.app.WebServer.main(WebServer.java:101)
2024.05.08 15:20:25 WARN  app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [Web Server]: 1
2024.05.08 15:20:25 INFO  app[][o.s.a.SchedulerImpl] Process[Web Server] is stopped
2024.05.08 15:20:25 INFO  app[][o.s.a.SchedulerImpl] Process[ElasticSearch] is stopped
2024.05.08 15:20:25 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped

Welcome :slight_smile:

documentation has only Java 17 in server installation requirerements

whereas for the Sonarqube analysis it has

A Java runtime environment:

  • Oracle JRE or OpenJDK.
  • Minimum version: Java 17.

Means it’s Java 17 for Sonarqube server and Java >= 17 for Sonarqube scanners.

Gilbert

But the documentation in this page shows it supports Java 21

https://portal.productboard.com/sonarsource/3-sonarqube/tabs/14-released-in-10-x

OK, you got that wrong.

this
https://portal.productboard.com/sonarsource/3-sonarqube/c/544-support-java-21

relates to the Sonar Java plugin being able to understand Java 21 syntax.
This has nothing to do with the Sonarqube server itself.

1 Like

ok thanks :slight_smile:

the initial answer did help – thanks for that

here is what i tried:

  • i tried a few versions of JDK 17 on my windows machine one by one.
    • openjdk 17 GA
    • openjdk 17.0.1
    • openjdk 17.0.2
    • openjdk 17.0.11
  • i tried setting system-environment-variable JAVA_HOME to the right version,
  • also set the JAVA_HOME/bin to the PATH variable
  • None of this was helping
  • i was still able to see this one in both sonar.log and es.log – it was picking up java 21 from Windows system (JRE)

so after doing some more research i added this variable in
conf/sonar.properties file

sonar.java.command=C:/Program Files/Java/openlogic-openjdk-17.0.11+9-windows-x64/bin/java

i also added yet another windows system-environment-variables ES_JAVA_HOME and SONAR_JAVA_HOME and set them to jdk 17 – i saw the ES_JAVA_HOME variable in /elasticsearch/bin/elasticsearch-env file
after this change i was able to get sonarqube running

i can now access sonarqube on localhost:9099
the first run of sonarqube has created necessary tables under the sonarqube database in Postgres successfully

thank you all for responding to the post

1 Like