Failing to analyse java 1.8 code with sonarqube 9.1.0

Here are details of versions used :

  • sonarQube : 9.1.0 with Java 11 ( jdk-11.0.12 )
  • Project source code is compiled in JDK 1.8 ( 1.8.0_191 )
  • maven version used - ( Apache Maven 3.6.3 )

The path variable points to JDK 1.8
To ensure sonarqube uses JDK 11 - made changes in : wrapper.conf

wrapper.java.command=C:\construction\tools\jdk-11.0.12\bin\java

So the server starts with a few errors but at the end of the logs indicates it has started up :

jvm 1    | 2021.11.01 10:10:29 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory C:\construction\tools\sonarqube-9.1.0.47736\temp
jvm 1    | 2021.11.01 10:10:29 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on [HTTP: 127.0.0.1:8765, TCP: 127.0.0.1:61672]
jvm 1    | 2021.11.01 10:10:29 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [C:\construction\tools\sonarqube-9.1.0.47736\elasticsearch]: C:\construction\tools\jdk-11.0.12\bin\java -XX:+UseG1GC -Djava.io.tmpdir=C:\construction\tools\sonarqube-9.1.0.47736\temp -XX:ErrorFile=../logs/es_hs_err_pid%p.log -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dio.netty.allocator.numDirectArenas=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Djava.locale.providers=COMPAT -Xmx512m -Xms512m -XX:MaxDirectMemorySize=256m -XX:+HeapDumpOnOutOfMemoryError -Delasticsearch -Des.path.home=C:\construction\tools\sonarqube-9.1.0.47736\elasticsearch -Des.path.conf=C:\construction\tools\sonarqube-9.1.0.47736\temp\conf\es -cp lib/* org.elasticsearch.bootstrap.Elasticsearch
jvm 1    | 2021.11.01 10:10:29 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
jvm 1    | 2021.11.01 10:10:31 ERROR app[][o.s.a.p.EsManagedProcess] Failed to check status
jvm 1    | org.elasticsearch.ElasticsearchException: java.util.concurrent.ExecutionException: java.net.ConnectException: Timeout connecting to [/127.0.0.1:8765]
jvm 1    | Caused by: java.net.ConnectException: Timeout connecting to [/127.0.0.1:8765]
jvm 1    |      at org.apache.http.nio.pool.RouteSpecificPool.timeout(RouteSpecificPool.java:169)
jvm 1    |      at org.apache.http.nio.pool.AbstractNIOConnPool.requestTimeout(AbstractNIOConnPool.java:628)
jvm 1    |      at org.apache.http.nio.pool.AbstractNIOConnPool$InternalSessionRequestCallback.timeout(AbstractNIOConnPool.java:894)
jvm 1    |      at org.apache.http.impl.nio.reactor.SessionRequestImpl.timeout(SessionRequestImpl.java:184)
jvm 1    |      at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processTimeouts(DefaultConnectingIOReactor.java:214)
jvm 1    |      at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:158)
jvm 1    |      at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:351)
jvm 1    |      at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:221)
jvm 1    |      at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64)
jvm 1    |      at java.base/java.lang.Thread.run(Thread.java:834)
jvm 1    | 2021.11.01 10:10:46 INFO  app[][o.s.a.SchedulerImpl] Process[es] is up
jvm 1    | 2021.11.01 10:10:46 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[[key='web', ipcIndex=2, logFilenamePrefix=web]] from [C:\construction\tools\sonarqube-9.1.0.47736]: C:\construction\tools\jdk-11.0.12\bin\java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=C:\construction\tools\sonarqube-9.1.0.47736\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 -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Dhttp.nonProxyHosts=localhost|127.*|[::1] -cp ./lib/sonar-application-9.1.0.47736.jar;C:\construction\tools\sonarqube-9.1.0.47736\lib\jdbc\h2\h2-1.4.199.jar org.sonar.server.app.WebServer C:\construction\tools\sonarqube-9.1.0.47736\temp\sq-process3557537997121009482properties
jvm 1    | 2021.11.01 10:11:00 INFO  app[][o.s.a.SchedulerImpl] Process[web] is up
jvm 1    | 2021.11.01 10:11:00 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[[key='ce', ipcIndex=3, logFilenamePrefix=ce]] from [C:\construction\tools\sonarqube-9.1.0.47736]: C:\construction\tools\jdk-11.0.12\bin\java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=C:\construction\tools\sonarqube-9.1.0.47736\temp -XX:-OmitStackTraceInFastThrow --add-opens=java.base/java.util=ALL-UNNAMED --add-exports=java.base/jdk.internal.ref=ALL-UNNAMED --add-opens=java.base/java.lang=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 -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Dhttp.nonProxyHosts=localhost|127.*|[::1] -cp ./lib/sonar-application-9.1.0.47736.jar;C:\construction\tools\sonarqube-9.1.0.47736\lib\jdbc\h2\h2-1.4.199.jar org.sonar.ce.app.CeServer C:\construction\tools\sonarqube-9.1.0.47736\temp\sq-process4498625566453455250properties
jvm 1    | 2021.11.01 10:11:05 INFO  app[][o.s.a.SchedulerImpl] Process[ce] is up
jvm 1    | 2021.11.01 10:11:05 INFO  app[][o.s.a.SchedulerImpl] SonarQube is up

when I run a normal command to compile my project ( spring boot ) - it runs fine with : mvn clean install

Now when I try to run below command :

mvn clean verify sonar:sonar -Dsonar.projectKey=mule_test -Dsonar.host.url=http://localhost:8090 -Dsonar.login=xyz

It fails with the following exception :

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155:sonar (default-cli) on project TreeSurveyAPI: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155:sonar: java.lang.UnsupportedClassVersionError: org/sonar/batch/bootstrapper/EnvironmentInformation has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.codehaus.mojo:sonar-maven-plugin:3.9.0.2155
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/c:/construction/maven_repository/org/sonarsource/scanner/maven/sonar-maven-plugin/3.9.0.2155/sonar-maven-plugin-3.9.0.2155.jar
[ERROR] urls[1] = file:/c:/construction/maven_repository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar
[ERROR] urls[2] = file:/c:/construction/maven_repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[3] = file:/c:/construction/maven_repository/org/codehaus/plexus/plexus-utils/3.2.1/plexus-utils-3.2.1.jar
[ERROR] urls[4] = file:/c:/construction/maven_repository/org/sonarsource/scanner/api/sonar-scanner-api/2.16.1.361/sonar-scanner-api-2.16.1.361.jar
[ERROR] urls[5] = file:/c:/construction/maven_repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

Was searching and found a few references like here and here

is any plugin required to be included in my project’s pom file ?
bug:fault

Hi,

Welcome to the community!

There are three different pieces here. The language version

  • the SonarQube server runs on: Java 11
  • your project compiles with: Java 8
  • your project analyzes with: Java 8 Java 11

You can still compile to/with Java 8, but you need to run analysis with Java 11.

 
HTH,
Ann