Properties from properties file ignored with SonarQube Scanner

I am evaluating the Enterprise version of SonarQube v7.9.1
My company is most interested in “C Family” analysis.
I used the wrapper to generate the directory “sonar_wrapper_outdir”, but attempts to scan the results always fails.
My properties file looks like this:


My scanner command looks like this:
sonar-scanner.bat -X -Dsonar.projectkey=com.myco.myproj -Dproject.settings=.\myproj_Sonar.Properties

The output looks like this–except that I performed some global replacements to obscure anything specific to my company. I also shortened it a bit by inserting “…etc…” in a few places. Note in the output that the scanner acknowledges the existence of my “Project root configuration file”, but does not use its settings (note the final line of the output which complains that sonar.projectKey is “Unknown” even though it is set in my properties file).
12:24:38.733 INFO: Scanner configuration file: C:\ExperimentalJenkins\tools\hudson.plugins.sonar.SonarRunnerInstallation\SonarQube-Scanner-Via-Maven-Central\bin…\conf\
12:24:38.743 INFO: Project root configuration file: D:\repos\myproj-Developer\subd1\subd2\subd3\subd4\subd5.\myproj_Sonar.Properties
12:24:38.793 INFO: SonarQube Scanner
12:24:38.793 INFO: Java 11.0.4 Oracle Corporation (64-bit)
12:24:38.793 INFO: Windows Server 2012 R2 6.3 amd64
12:24:38.995 DEBUG: keyStore is :
12:24:38.995 DEBUG: keyStore type is : pkcs12
12:24:38.995 DEBUG: keyStore provider is :
12:24:38.996 DEBUG: init keystore
12:24:38.996 DEBUG: init keymanager of type SunX509
12:24:39.334 DEBUG: Create: C:\Users\TheBuilder.sonar\cache
12:24:39.335 INFO: User cache: C:\Users\TheBuilder.sonar\cache
12:24:39.335 DEBUG: Create: C:\Users\TheBuilder.sonar\cache_tmp
12:24:39.339 DEBUG: Extract sonar-scanner-api-batch in temp…
12:24:39.345 DEBUG: Get bootstrap index…
12:24:39.346 DEBUG: Download: http://tmpsonar:9000/batch/index
12:24:39.429 DEBUG: Get bootstrap completed
12:24:39.436 DEBUG: Create isolated classloader…
12:24:39.450 DEBUG: Start temp cleaning…
12:24:39.482 DEBUG: Temp cleaning done
12:24:39.482 DEBUG: Execution getVersion
12:24:39.501 INFO: SonarQube server 7.9.1
12:24:39.501 INFO: Default locale: “en_US”, source code encoding: “windows-1252” (analysis is platform dependent)
12:24:39.503 DEBUG: Work directory: D:\repos\myproj-Developer\subd1\subd2\subd3\subd4\subd5.scannerwork
12:24:39.504 DEBUG: Execution execute
12:24:40.029 DEBUG: Enterprise
12:24:40.208 INFO: Load global settings
12:24:40.265 DEBUG: GET 200 http://tmpsonar:9000/api/settings/values.protobuf | time=53ms
12:24:40.334 INFO: Load global settings (done) | time=126ms
12:24:40.344 INFO: Server id: A7EE8CF2-AWskbYe-bAlVzurgyKKJ
12:24:40.370 INFO: User cache: C:\Users\TheBuilder.sonar\cache
12:24:40.375 INFO: Load/download plugins
12:24:40.375 INFO: Load plugins index
12:24:40.385 DEBUG: GET 200 http://tmpsonar:9000/api/plugins/installed | time=10ms
12:24:40.456 INFO: Load plugins index (done) | time=81ms
12:24:40.829 INFO: Load/download plugins (done) | time=455ms
12:24:41.169 DEBUG: Plugins:
12:24:41.170 DEBUG: * Cobertura 2.0 (cobertura)
12:24:41.170 DEBUG: * SonarCSS (cssfamily)
12:24:41.172 DEBUG: * SonarCFamily (cpp)
12:24:41.174 DEBUG: * Vulnerability Rules for PHP (securityphpfrontend)
12:24:41.219 INFO: Loaded core extensions: developer-scanner
12:24:41.274 DEBUG: Installed core extension: developer-scanner
12:24:42.305 INFO: Process project properties
12:24:42.315 INFO: ------------------------------------------------------------------------
12:24:42.315 INFO: ------------------------------------------------------------------------
12:24:42.316 INFO: Total time: 3.636s
12:24:42.355 INFO: Final Memory: 5M/27M
12:24:42.355 INFO: ------------------------------------------------------------------------
12:24:42.355 ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.ProjectLock
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(
at org.picocontainer.DefaultPicoContainer.getComponent(
at org.sonar.core.platform.ComponentContainer.getComponentByType(
at org.sonarsource.scanner.cli.Main.execute(
at org.sonarsource.scanner.cli.Main.execute(
at org.sonarsource.scanner.cli.Main.main(
Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.api.batch.fs.internal.DefaultInputProject
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(
at org.picocontainer.DefaultPicoContainer.getComponent(
at org.picocontainer.DefaultPicoContainer.getComponent(
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(
… 22 more
Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.api.batch.bootstrap.ProjectReactor
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(
at org.picocontainer.DefaultPicoContainer.getComponent(
at org.picocontainer.DefaultPicoContainer.getInstance(
at org.picocontainer.DefaultPicoContainer.getComponent(
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(
… 36 more
Caused by: You must define the following mandatory properties for ‘Unknown’: sonar.projectKey

What am I doing wrong?

It looks like a problem with installed plugins or version of the SonarScanner. Use the latest version of SonarScanner and check if your all your plugins are compatible with your server version :wink:

Thank you for your reply Adam.
I double checked that all plugins are up-to-date. SonarCFamily 6.3(build 11371).
The scanner is the most current available,
The problem persists.

I noticed that there is a sonar-scanner-debug.bat, so I tried executing that instead of the sonar-scanner.bat, but it seems to hang here:
Listening for transport dt_socket at address: 8000


What catches my eye in this:

Is “-Dproject.settings=…”. As far as I know, this has never been a recognized property. The dead giveaway here is that it doesn’t start with sonar.. :slight_smile: That’s probably why you’re having to specify project key on the command line; your project properties aren’t being read.

Also, since your analysis logs show that your global settings are being picked up, there ought to be no need to specify the the host URL on the command line.

I recommend you move your properties file to the standard name/location: in the project root, and try reanalyzing with a simpler command line: sonar-scanner.bat.


Thank you Ann.

Prompting me to move things to a more standard location may have been the thing that helped most.
Previously, my properties file was in a subdirectory of the Git repository–close to the VStudio solutions file (i.e., it was on D:\repos\myproj-Developer\subd1\subd2\subd3\subd4\subd5.\myproj_Sonar.Properties).

I moved myproj_Sonar.Properties to D:\repos\myproj-Developer\ (i.e., to the standard name at the root of the repo) and the scan succeeded with:
sonar-scanner.bat -X

I’ll also note that the scan succeed with a properties file using the non-default name. So, after renaming to myproj_Sonar.Properties (still at the root of the repo), the scan succeed with:
sonar-scanner.bat -X -Dproject.settings=myproj_Sonar.Properties

The -Dproject.settings property is used by the “SonarQube Scanner for Jenkins” plugin. That’s where I saw its usage.

It’s odd to me that I needed to run the scanner from the root of the Git repository, but, for now, I’ll accept that and move on. I’m happy to be making some progress.


I’m glad you got this working. Just for the record, I want to point out that normally your would be configured in the scanner’s own global configuration file, eliminating the need to specify it on the command line.