Error during SonarQube Scanner execution - NullPointerException

Failed During upload to Sonar.
I Run BuildWrapper on a remote host, than I ran the upload tool on different host.
I already have this project uploaded to Sonar.

  • Enterprise Edition
  • Version 7.9 (build 26994)

17:58:04.477 ERROR: Error during SonarQube Scanner execution
java.lang.NullPointerException
at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:265)
at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:205)
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:400)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:395)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:358)
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:73)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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:171)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:128)
at org.sonarsource.scanner.cli.Main.execute(Main.java:111)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)

Hi @benyahu,

what version of SonarCFamily plugin do you have?
Could you update SonarCFamily analyzer to its latest version 6.6 and rerun the analysis?

Hi have 6.3
Will update and update here for status

1 Like

After updating, still got the same issue.
Also got suggestion to add - sonar.cfamily.cache.enabled=false, so I did it.
java.lang.NullPointerException
at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:417)
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:400)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:395)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:358)
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:73)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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:171)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:128)
at org.sonarsource.scanner.cli.Main.execute(Main.java:111)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)

Hi @benyahu,

could you please share the build-wrapper folder content?

buildWrapper.7z.txt (411.7 KB) build-wrapper-dump.json.txt (4.0 MB)

I upload it, and the buildwrapper is zipped.

Hi @benyahu,

from build-wrapper.log it seems that you are using build-wrapper 6.1:

Thu Dec 19 14:07:20 2019: build-wrapper, version 6.1 (linux-x86)

Could you please retry with build-wrapper 6.6?
You can download it from: {SonarQube URL}/static/cpp/build-wrapper-linux-x86.zip where {SonarQube URL} is the url to your SonarQube instance.

If the problem persist could you please share again the build-wrapper folder content and the sonar-scanner output log with the new version?

11:59:27.287 DEBUG: ‘src/vma/infra/sender_info_dst.h’ generated metadata with charset ‘UTF-8’
11:59:27.289 WARN:
SonarCFamily plugin supports incremental analysis with the use of a cache:

  • if you do not want to enable cache explicitly disable it by setting the following property to your analysis: sonar.cfamily.cache.enabled=false
  • to enable cache please specify the following 2 options and visit the documentation page for more information (http://sonar.mellanox.com:9000/documentation/analysis/languages/cfamily/):
    • sonar.cfamily.cache.enabled=true
    • sonar.cfamily.cache.path=relative_or_absolute_path_to_cache_location

11:59:27.386 INFO: Subprocess(es) done in 97ms
11:59:27.386 INFO: 0 compilation units analyzed
11:59:27.408 INFO: ------------------------------------------------------------------------
11:59:27.408 INFO: EXECUTION FAILURE
11:59:27.408 INFO: ------------------------------------------------------------------------
11:59:27.408 INFO: Total time: 8.040s
11:59:27.619 INFO: Final Memory: 59M/2637M
11:59:27.619 INFO: ------------------------------------------------------------------------
11:59:27.619 ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: The “build-wrapper-dump.json” file was found but 0 C/C++/Objective-C files were analyzed. Please make sure that:

  • you are using the latest version of the build-wrapper and the SonarCFamily analyzer
  • you are correctly invoking the scanner with correct configuration * your compiler is supported
  • you are wrapping your build correctly
  • you are wrapping a full/clean build
  • you are providing the path to the correct build-wrapper output directory
    at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:356)
    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:400)
    at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:395)
    at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:358)
    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:73)
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
    at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    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:171)
    at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:128)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:111)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
    at org.sonarsource.scanner.cli.Main.main(Main.java:61)

MAKE_OUT-buildwrapper.7z.txt (221.7 KB)

Hi @benyahu,

the build-wrapper-dump.json seems good, it may be related to the sonar-scanner properties. Could you please share the output log of sonar-scanner with --debug option?

sonar.txt (87.9 KB)

Hi @benyahu,

the issue comes from the fact that you are building the source files in:

/tmp/daily_vma_build/libvma/src/vma

and you analyze them from:

/builds2/ci_builds/fit71_jenkins_master/workspace/Rivermax_VMA_upload_results_to_sonar/VMA/

The analyzer needs to match the paths in the build-wrapper-dump.json to the analyzed files which means you should build and analyze the same sources checkout.

So what I can do if I have one machine that build and one machine to upload ?
It should run from the same paths ?

Hi @benyahu,

you should build and analyze on the same machine, it is a prerequisite, you cannot build and analyze in two different machines.