Maven Plugin can Upload but Scanner cannot

Hi All,

I am having an interesting problem.
I set up a new build server.
I scan both java maven projects and nodejs react projects on this server.
I scan java maven projects with sonar maven plugin and nodejs react projects with sonar-scanner.
I send both scan results to sonar server.
But while I have no problem on sonar maven plugin side, I get an error in the loading step on sonar-scanner side.

Thinking that this is an ssl problem, I added a certificate to cacerts in scanner java and tried to run it by showing another directory jks. I set this jks as env path. None of them worked. There is no ssl or certificate setting on maven side anyway.

add: There is access to the sonar server from the build server. User permissions are OK. I can call the sonar APIs with loginid.

I am sharing some logs below, can anyone help me with this?

Maven Plugin Log

[INFO] --- sonar-maven-plugin:5.0.0.4389:sonar (default-cli) @ mavenapp---
[WARNING] Using an unspecified version instead of an explicit plugin version may introduce breaking analysis changes at an unwanted time. It is highly recommended to use an explicit version, e.g. 'org.sonarsource.scanner.maven:sonar-maven-plugin:5.0.0.4389'.
[INFO] Java 17.0.10 Oracle Corporation (64-bit)
[INFO] Linux 5.14.0-427.35.1.el9_4.x86_64 (amd64)
[INFO] User cache: /home/bamboo/.sonar/cache
[INFO] Communicating with SonarQube Server 9.9.3.79811
[INFO] Load global settings
[INFO] Load global settings (done) | time=152ms
[INFO] Server id: $deleted-by-me$
[INFO] User cache: /home/bamboo/.sonar/cache
[INFO] Load/download plugins
[INFO] Load plugins index
[INFO] Load plugins index (done) | time=83ms
[INFO] Load/download plugins (done) | time=132ms
[INFO] Process project properties
[INFO] Process project properties (done) | time=7ms
[INFO] Execute project builders
[INFO] Execute project builders (done) | time=1ms
[INFO] Project key: $deleted-by-me$
[INFO] Base dir: /data/atlassian/bamboo-9.5.4/local-working-dir/$deleted-by-me$
[INFO] Working dir: /data/atlassian/bamboo-9.5.4/local-working-dir/$deleted-by-me$/.sonar
[INFO] Load project settings for component key: 'mavenapp'
[INFO] Load project settings for component key: 'mavenapp' (done) | time=33ms
[INFO] Auto-configuring with CI 'Bamboo'
...
SOME LOADING DATA
...
[INFO] ------------- Run sensors on module $deleted-by-me$
...
SOME LOADING DATA
...
[INFO] ------------- Run sensors on project
[INFO] Sensor Analysis Warnings import [csharp]
[INFO] Sensor Analysis Warnings import [csharp] (done) | time=4ms
[INFO] Sensor Zero Coverage Sensor
[INFO] Sensor Zero Coverage Sensor (done) | time=6ms
[INFO] Sensor Java CPD Block Indexer
[INFO] Sensor Java CPD Block Indexer (done) | time=361ms
[INFO] CPD Executor 131 files had no CPD blocks
[INFO] CPD Executor Calculating CPD for 344 files
[INFO] CPD Executor CPD calculation finished (done) | time=144ms
[INFO] Analysis report generated in 167ms, dir size=4.3 MB
[INFO] Analysis report compressed in 944ms, zip size=2.0 MB
[INFO] Analysis report uploaded in 9607ms
[INFO] ANALYSIS SUCCESSFUL, you can find the results at: https://mysonar.prj.address
[INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
[INFO] More about the report processing at https://mysonar/sonar/api/ce/task?id=blablablaid
[INFO] Analysis total time: 50.749 s
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

Sonar Scanner Log

Sonar Scanner Script Starting
---------------------------------------
Command: sonar-scanner -Dsonar.projectKey=myapp -Dsonar.projectName=myapp -Dsonar.projectVersion=1.0.0

NOTE: Picked up JDK_JAVA_OPTIONS:  --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
INFO: Scanner configuration file: /obss/tool/sonarqube/scanner/sonar-scanner-5.0.1.3006-linux/conf/sonar-scanner.properties
INFO: Project root configuration file: /data/atlassian/bamboo-9.5.4/local-working-dir/10780674/myapp/src/main/javascript/sonar-project.properties
INFO: SonarScanner 5.0.1.3006
INFO: Java 17.0.7 Eclipse Adoptium (64-bit)
INFO: Linux 5.14.0-427.35.1.el9_4.x86_64 amd64
INFO: User cache: /home/bamboo/.sonar/cache
INFO: Analyzing on SonarQube server 9.9.3.79811
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Load global settings
INFO: Load global settings (done) | time=152ms
INFO: Server id: 46AFA890-AWWPHJ4NSYK4B8weeutz
INFO: User cache: /home/bamboo/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=53ms
INFO: Load/download plugins (done) | time=224607ms
INFO: Process project properties
INFO: Process project properties (done) | time=7ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=1ms
INFO: Project key: myapp:myapp
INFO: Base dir: /data/atlassian/bamboo-9.5.4/local-working-dir/10780674/myapp:myapp/src/main/javascript
INFO: Working dir: /data/atlassian/bamboo-9.5.4/local-working-dir/10780674/myapp:myapp/src/main/javascript/.scannerwork
INFO: Load project settings for component key: 'myapp:myapp'
INFO: Auto-configuring with CI 'Bamboo'
..
SOME LOADING DATA
...
[INFO] ------------- Run sensors on module $deleted-by-me$
...
SOME LOADING DATA
...
INFO: ------------- Run sensors on myapp
INFO: Sensor Analysis Warnings import [csharp]
INFO: Sensor Analysis Warnings import [csharp] (done) | time=1ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=2ms
INFO: SCM Publisher SCM provider for this project is: git
INFO: SCM Publisher 130 source files to be analyzed
INFO: This git repository references another local repository which is not well supported. SCM information might be missing for some files. You can avoid borrow objects from another local repository by not using --reference or --shared when cloning it.
INFO: SCM Publisher 130/130 source files have been analyzed (done) | time=932ms
INFO: CPD Executor 30 files had no CPD blocks
INFO: CPD Executor Calculating CPD for 64 files
INFO: CPD Executor CPD calculation finished (done) | time=88ms
INFO: Analysis report generated in 90ms, dir size=751.2 kB
INFO: Analysis report compressed in 191ms, zip size=491.5 kB
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 5:02.496s
ERROR: Error during SonarScanner execution
INFO: Final Memory: 19M/80M
INFO: ------------------------------------------------------------------------
java.lang.IllegalStateException: Failed to upload report: Fail to request url: https://mysonar/sonar/api/ce/submit?projectKey=myappblabla
        at org.sonar.scanner.report.ReportPublisher.upload(ReportPublisher.java:226)
        at org.sonar.scanner.report.ReportPublisher.execute(ReportPublisher.java:154)
        at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:376)
        at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
        at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
        at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:137)
        at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
        at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
        at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
        at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
        at jdk.proxy1/jdk.proxy1.$Proxy0.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.cli.Main.execute(Main.java:126)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
        at org.sonarsource.scanner.cli.Main.main(Main.java:62)
Caused by: java.lang.IllegalStateException: Fail to request url: https://mysonar/sonar/api/ce/submit?projectKey=myappblabla
        at org.sonarqube.ws.client.HttpConnector.doCall(HttpConnector.java:208)
        at org.sonarqube.ws.client.HttpConnector.post(HttpConnector.java:158)
        at org.sonarqube.ws.client.HttpConnector.call(HttpConnector.java:115)
        at org.sonar.scanner.bootstrap.DefaultScannerWsClient.call(DefaultScannerWsClient.java:87)
        at org.sonar.scanner.report.ReportPublisher.upload(ReportPublisher.java:224)
        ... 21 more
Caused by: java.net.SocketException: Connection reset
        at java.base/sun.nio.ch.NioSocketImpl.implRead(Unknown Source)
        at java.base/sun.nio.ch.NioSocketImpl.read(Unknown Source)
        at java.base/sun.nio.ch.NioSocketImpl$1.read(Unknown Source)
        at java.base/java.net.Socket$SocketInputStream.read(Unknown Source)
        at java.base/sun.security.ssl.SSLSocketInputRecord.read(Unknown Source)
        at java.base/sun.security.ssl.SSLSocketInputRecord.readHeader(Unknown Source)
        at java.base/sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(Unknown Source)
        at java.base/sun.security.ssl.SSLSocketImpl.readApplicationRecord(Unknown Source)
        at java.base/sun.security.ssl.SSLSocketImpl$AppInputStream.read(Unknown Source)
        at okio.InputStreamSource.read(JvmOkio.kt:93)
        at okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:128)
        at okio.RealBufferedSource.indexOf(RealBufferedSource.kt:430)
        at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.kt:323)
        at okhttp3.internal.http1.HeadersReader.readLine(HeadersReader.kt:29)
        at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:178)
        at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:106)
        at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:79)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at org.sonarqube.ws.client.OkHttpClientBuilder.addHeaders(OkHttpClientBuilder.java:222)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
        at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
        at org.sonarqube.ws.client.HttpConnector.doCall(HttpConnector.java:206)
        ... 25 more
ERROR:
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
---------------------------------------
Return code of command is 1
Command has failed!

I noticed you have two different Java versions for the two different scanners.

Maven

Scanner CLI

Maybe something is weird in your environment with this 17.0.7 JRE (I believe it is the one embedded in the 5.0.1 Linux scanner)

You can test this by downloading the Any flavor of the SonarScanner CLI which does not embed a JRE. At that point, it will use whatever the JAVA_HOME environment variable is set to (probably this 17.0.10 install).

Would be interesting to know why one works and the other doesn’t, but let’s start by getting it working!