java.lang.IllegalStateException: The "build-wrapper-dump.json" file was found empty

Hello Team,

now am getting below issue please help .

85688.png

Hello Team,

PF the file for build wrapper output directory

// example for Windows
build-wrapper-win-x86-64.exe --out-dir  build_wrapper_output_directory MSBuild.exe /t:Rebuild

Thanks,
Nagendra.J.

build-wrapper-dump.json (7.61 KB)

Please note that the result of the sonar-scanner command must succeed to get any results on SonarQube. And if I understood you correctly, the result of this command is still failing in your case, so that’s why you don’t see anything on SonarQube.

So, first things first, let’s try to make your sonar-scanner command successful.
Now I can see your build-wrapper.json is not empty anymore, so launching the build wrapper with a clean build was already a good step.
But to investigate further, I would need the whole content of the build_wrapper_output_directory, not only the json file.
And if you could also send me the logs you get when launching build-wrapper-win-x86-64.exe --out-dir build_wrapper_output_directory MSBuild.exe /t:Rebuild, it would be helpful.
Thanks

Hello Team,

As mentioned attached whole content of the build_wrapper_output_directory.And the analysis is successful but the code is not deployed in sonar server( the issue is :

The main branch has no lines of code.

``

12:29:31.000 INFO: Analysis report generated in C:\Users\SRL-03\3D Objects\cpp_updater\cpp_updater.scannerwork\scanner-report
12:29:31.003 DEBUG: Upload report
12:29:31.934 DEBUG: POST 200 http://172.20.1.131:9000/api/ce/submit?projectKey=CPPUpdaterClient&projectName=CPPUpdater | time=925ms
12:29:31.945 INFO: Analysis report uploaded in 938ms
12:29:31.948 DEBUG: Report metadata written to C:\Users\SRL-03\3D Objects\cpp_updater\cpp_updater.scannerwork\report-task.txt
12:29:31.949 INFO: ANALYSIS SUCCESSFUL, you can browse http://172.20.1.131:9000/dashboard?id=CPPUpdaterClient
12:29:31.950 INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
12:29:31.952 INFO: More about the report processing at http://172.20.1.131:9000/api/ce/task?id=AXlAeYEuoXVWa5Ul5XfV
12:29:31.956 DEBUG: Post-jobs :
12:29:31.959 INFO: Analysis total time: 21.601 s
12:29:31.963 INFO: ------------------------------------------------------------------------
12:29:31.963 INFO: EXECUTION SUCCESS
12:29:31.964 INFO: ------------------------------------------------------------------------
12:29:31.965 INFO: Total time: 35.341s
12:29:32.034 INFO: Final Memory: 7M/27M
12:29:32.034 INFO: ---------------------------------

Thanks,
Nagendra.

build_wrapper_output_directory.zip (6.21 KB)

Please help me on this isue, today is last date for free license, i need to done POC

To sum up, and please read this carefully and check that is indeed what you’re doing:

  • You’re at the root of your project that contains .cpp files.
  • You launch a clean build with build-wrapper: build-wrapper-win-x86-64.exe --out-dir build_wrapper_output_directory MSBuild.exe /t:Rebuild
    With build_wrapper_output_directory the same directory that is defined in your sonar-project.properties (i.e.: sonar.cfamily.build-wrapper-output=build_wrapper_output_directory)
  • You launch sonar-scanner
  • You go to your SonarQube (with the same URL than the one defined in sonar-project.properties, i.e. sonar.host.url=YourSonarQubeURL)

And then you have the message “The main branch has no lines of code”, and don’t have any results.
Is that correct?

If so, please share with me your sonar-project.properties so that I can try to figure out the problem.

Hello Team,

As you requested ,Please find the attached sonar-project.propeties file,If any i mistaken in that please guide those

queries:

  1. For cpp how to give the exclude source code files like

sonar.inclusions=
sonar.exclusions=

I have deployed sonar sonar in docker and i trying do code analysis from another windows server using sonar-scanner is that fine .

Regards,
Nagendra.J

(Attachment sonar-project.properties is missing)

Hello Team,

As you requested ,Please find the attached sonar-project.propeties file,If any i mistaken in that please guide those

queries:

  1. For cpp how to give the exclude source code files like

sonar.inclusions=
sonar.exclusions=

I have deployed sonar sonar in docker and i trying do code analysis from another windows server using sonar-scanner is that fine .

Regards,
Nagendra.J

sonar-project.zip (631 Bytes)

In your sonar-project.properties:

  • Please remove sonar.language=C++, this has been deprecated and is not useful here
  • What do you want to achieve by writing this:
    sonar.inclusions=*.cpp
    sonar.exclusions=*.cpp
    These properties take as input a relative path to the files you want to include/exclude.
    If you want to exclude a particular file, it would look something like:
    sonar.exclusions=my/path/to/myFile.cpp

For the analysis to work correctly, build and analysis should be done on the same environment, because we need to access the same files used during build in order to get you accurate analysis. It does not seem to be your case from what you describe, so that’s why it does not work.

Hello Team,

I tried as you mentioned steps,But getting below issue

i have Modified sonar.proeject propeties file,but still getting issue please check

Thanks,
Nagendra.J

Hello Team,

I tried as you mentioned steps,But getting below issue

i have Modified sonar.proeject propeties file,but still getting issue please check

17:37:33.825 DEBUG: ‘Indexer.cpp’ generated metadata with charset ‘UTF-8’
17:37:33.843 DEBUG: ‘packages/curl-vc140-static-32_64.7.53.0/lib/native/include/curl/typecheck-gcc.h’ generated metadata with charset ‘UTF-8’
17:37:33.890 DEBUG: ‘packages/openssl-vc140-static-32_64.1.1.0/lib/native/include/openssl/ssl2.h’ generated metadata with charset ‘UTF-8’
17:37:33.895 DEBUG: ‘ServerInfoStruct.h’ generated metadata with charset ‘UTF-8’
17:37:33.897 DEBUG: Not enough content in ‘ServerInfoStruct.h’ to have CPD blocks, it will not be part of the duplication detection
17:37:33.995 INFO: ------------------------------------------------------------------------
17:37:33.996 INFO: EXECUTION FAILURE
17:37:33.996 INFO: ------------------------------------------------------------------------
17:37:33.997 INFO: Total time: 16.093s
17:37:34.047 INFO: Final Memory: 19M/74M
17:37:34.047 INFO: ------------------------------------------------------------------------
17:37:34.048 ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: java.nio.file.NoSuchFileException: C:\Users\SRL-03\3D Objects\cpp_updater\cpp_updater\cpp_updater\build_wrapper_output_directory\build-wrapper-dump.json
at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:611)
at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:360)
at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:166)
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:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:392)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:388)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:357)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:149)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
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)
Caused by: java.nio.file.NoSuchFileException: C:\Users\SRL-03\3D Objects\cpp_updater\cpp_updater\cpp_updater\build_wrapper_output_directory\build-wrapper-dump.json
at java.base/sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at java.base/sun.nio.fs.WindowsFileSystemProvider.newByteChannel(Unknown Source)
at java.base/java.nio.file.Files.newByteChannel(Unknown Source)
at java.base/java.nio.file.Files.newByteChannel(Unknown Source)
at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(Unknown Source)
at java.base/java.nio.file.Files.newInputStream(Unknown Source)
at java.base/java.nio.file.Files.newBufferedReader(Unknown Source)
at java.base/java.nio.file.Files.newBufferedReader(Unknown Source)
at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:537)
… 30 more

C:\Users\SRL-03\3D Objects\cpp_updater\cpp_updater\cpp_updater>sonar-scanner -Dsonar.login=8271819e7474f918d88439db7a44ac99d83098f0 -X

Thanks,
Nagendra.j

sonar-project.zip (658 Bytes)

Hello Team,

Please ignore last mail now i am getting below issue after modifying project properties file

18:06:44.726 ERROR: Error during SonarScanner 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 CFamily 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
  • you are building and analyzing the same source checkout, absolute paths must be identical in build and analysis steps
    at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:440)
    at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:166)
    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:137)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
    at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:392)
    at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:388)
    at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:357)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
    at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:149)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
    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)

Thanks,
nagendra.j

sonar-project.zip (658 Bytes)

Can you confirm that you’re doing both compilation with build-wrapper and analysis in the same environment?
If not, it can not work.

If so, as before, please share the entire log output of your clean build command with the build wrapper as well as the files that are in your build_wrapper_output_directory

Hello Team,

  1. No i am doing compilation with build-wrapper in the different environment

and analysis is in the different environment, This steps i need to do now and update about this logs

2 .Already i have shared build_wrapper_output_directory ,anyways i am sending again pls PF attached with this mail.

  1. I have deployed sonar server is that fine?
    For docker based i need to follow any other process?

Thanks,
Nagendra.J

sonar-project.zip (658 Bytes)

I’m sorry but if you do the compilation and the analysis in two different environments, it can’t work.

Hello Team,

As you said, I tried compilation for both build-wrapper and sonar scanning in same environment,the sonar-scanner -X command executed successful , But still no luck, i found another issue ,Please find that issues screen-shots attached with this mail

Thanks,
Nagendra.Jonnalagadda.

Hello @nagendra_jonnalagadd,

It’s hard to tell what’s wrong with two screenshots.
It seems that no file has been found to be analyzed. Can you confirm the build-wrapper was called with a clean build command?
If so, please share the following: build-wrapper-dump.json, build-wrapper.log as well as the output of the sonar-scanner command

@Team , i resolved issue what i sent before mail, Now am getting results in sonar server. Please check screen-shot and update is it correct out-put or not.

I’m not sure what you want us to say from this screenshot… It seems you have results indeed, so that’s good.

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