java.lang.NumberFormatException while running sonar-scanner

Almost identical to topic #39181, but with different versions.

  • Environment:
INFO: SonarQube Scanner 4.2.0.1873
INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
INFO: Linux 4.15.0-129-generic amd64
  • Versions used:
SonarQube Enterprise server 8.0.0.29455
sonar-scanner 4.2.0.1873
build-wrapper 6.20
SonarCFamily 6.8.0.16475
  • Error message:
java.lang.NumberFormatException: Expected an int but was 6.20 at line 9 column 17
	at com.google.gson.stream.JsonReader.nextInt(JsonReader.java:1181)
	at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:410)
	at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:277)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:62)
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:387)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:383)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:346)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
	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 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:112)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
	at org.sonarsource.scanner.cli.Main.main(Main.java:61)

I have checked sonar-scanner version for 8.0:
https://docs.sonarqube.org/8.0/analysis/scan/sonarscanner/

Build wrapper, we grab from the server as documented:
https://docs.sonarqube.org/8.0/analysis/languages/cfamily/

Download Build Wrapper for Linux from {SonarQube URL}/static/cpp/build-wrapper-linux-x86.zip

I have checked the plugin version matrix and it seems the c-family plugin is okay:
https://docs.sonarqube.org/8.0/instance-administration/plugin-version-matrix/

Anything else I should check for?

Hi @Won-Mean_Lee ,

you are using a new build-wrapper with an old version of the plugin, they should have the same version 6.8.

I am not sure you are downloading the build-wrapper from the same server you are running the analysis, you are either downloading it from a SonarQube 8.9 server or from SonarCloud.

You should eventually consider upgrading to a newer version.

Thank you, I will pass this along to the devops team!

Aha, we have at least two separate servers… one is on 8.0 and another on 8.9.

Hi @Won-Mean_Lee ,

that is why it is good to always download the build-wrapper at run time from the analysis server. Did you manage to fix your issue? Shall I consider this topic as closed?

Yep, we had a server url mismatch between the docker and jenkins script.
Yes, fixed. Please close. Thank you!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.