Sonar-scanner throwing frequent errors for metrics and hostname but not always

Hello,
I have a repeating issue when using sonar-scanner in Jenkins to scan a project the issue happens sometimes, For example I can do the build first and it throws the error and then after 5 mins do another build and it will go.

The error that I’m getting is happening first when the sonar-scanner is trying to reach the metrics and throwing this error

INFO: Load metrics repository
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 2:31.845s
INFO: Final Memory: 12M/114M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.sensor.ModuleSensorsExecutor
	at org.sonar.core.platform.SpringComponentContainer.getComponentByType(SpringComponentContainer.java:139)
	at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(SpringModuleScanContainer.java:82)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
	at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:401)
	at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:397)
	at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:366)
	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:135)
	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(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at com.sun.proxy.$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: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.sonarsource.scanner.api.internal.IsolatedClassloader@3232a28a-org.sonar.scanner.sensor.ModuleSensorsExecutor': Unsatisfied dependency expressed through constructor parameter 0; nested exception is 

after reading the whole thing i see the problem is with one the metrics and second reaching the hostname

Caused by: java.lang.IllegalStateException: Unable to load metrics
	at org.sonar.scanner.repository.DefaultMetricsRepositoryLoader.load(DefaultMetricsRepositoryLoader.java:47)
	at org.sonar.scanner.repository.MetricsRepositoryProvider.provide(MetricsRepositoryProvider.java:35)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
	... 114 more
Caused by: java.lang.IllegalStateException: Fail to request url: https://<URL>.com/api/metrics/search?ps=500&p=1
	at org.sonarqube.ws.client.HttpConnector.doCall(HttpConnector.java:208)
	at org.sonarqube.ws.client.HttpConnector.get(HttpConnector.java:125)
	at org.sonarqube.ws.client.HttpConnector.call(HttpConnector.java:112)
	at org.sonar.scanner.bootstrap.DefaultScannerWsClient.call(DefaultScannerWsClient.java:87)
	at org.sonar.scanner.repository.DefaultMetricsRepositoryLoader.loadFromPaginatedWs(DefaultMetricsRepositoryLoader.java:57)
	at org.sonar.scanner.repository.DefaultMetricsRepositoryLoader.load(DefaultMetricsRepositoryLoader.java:45)
	... 120 more
Caused by: javax.net.ssl.SSLPeerUnverifiedException: Hostname <URL>.com not verified (no certificates)
	at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.kt:396)
	at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.kt:337)
	at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:209)
	at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226)
	at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
	at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
	at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
	at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
	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)
	... 125 more

but if i run the build after this error it goes as it should
the command I’m using to do the sonar scan is as follow
${scannerHome}/bin/sonar-scanner -Djdk.tls.client.protocols=TLSv1.2 -Dsonar.projectKey=‘name’ -Dsonar.java.binaries=.

I dont have an idea why this is happening, any idea?

Hey there.

As requested in the template post, what version of SonarQube are you using?

I’m using Version 9.8 (build 63668)
Jenkins [Jenkins 2.346]
[SonarQube ScannerVersion 2.15 ]

Thanks.

Is it possible that these builds are running on different build agents (jenkins nodes), which might have Java/certificates configured differently?

I only have one Jenkins node not multiple and the problem is it doesn’t do that all time some builds and some not.
and to be extra clear these are the sonarqube Global configs and inline cnfigs

sh "${scannerHome}/bin/sonar-scanner -Djdk.tls.client.protocols=TLSv1.2 -Dsonar.projectKey='Project' -Dsonar.java.binaries=."

also i’m using JDK 11 from openjdk (11.0.2 (build 11.0.2+9))

That’s quite an old version of Java 11, known to have some issues. Can you use the latest version of Java 11?

can i use a hire version of java like jdk 12 or 17?

I suggest using an LTS version of Java, right now either Java 11 or Java 17 (the latest version of either).

Ok i upgraded the jdk to the latest JDK 11.0.19 and I’m gonna monitor it for a few days and see what happens

1 Like

thanks for the advice I updated to the latest jdk 11.0.19 and till today there was no error i can consider this solved but ill keep the monitoring but thanks for the advice.

1 Like