1
votes

I am doing a POC for .Net projects by using SONAR. My 1st attempt is to only evaluate the code coverage of my Mock tests. So far I have installed in my sandbox (Win7) the below apps:

  • SONAR 3.7.3
  • SONAR RUNNER 2.3

My sonar website is hosted in the default url localhost:9000 and I am able to see on the browser. I have created a sonar-project.propeties file under the same folder where my sln file is My sonar-project.propeties looks like this:

# required metadata
sonar.projectKey=my:project
sonar.projectName=My project
sonar.projectVersion=1.0
sonar.sources=.
sonar.language=cs

My problem comes when I execute the sonar-runner on the sane folder, which throws the below error message:

INFO: ------------------------------------------------------------------------ INFO: EXECUTION FAILURE INFO: ------------------------------------------------------------------------ Total time: 2.767s Final Memory: 5M/20M INFO: ------------------------------------------------------------------------ ERROR: Error during Sonar runner execution ERROR: Unable to execute Sonar ERROR: Caused by: You must define the following mandatory properties for 'Unknow n': sonar.projectKey, sonar.projectName, sonar.projectVersion, sonar.sources ERROR: ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with t he -e switch. ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.

Any idea what might be causing this? I believe that I am not missing nothing.

Additonal Infomation

When I execute the sonar-runner with the flag -e i get the below message:

INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 20.841s
Final Memory: 12M/110M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher
.java:91)
        at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
        at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
        at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102
)
        at org.sonar.runner.api.Runner.execute(Runner.java:90)
        at org.sonar.runner.Main.executeTask(Main.java:70)
        at org.sonar.runner.Main.execute(Main.java:59)
        at org.sonar.runner.Main.main(Main.java:41)
Caused by: org.sonar.api.utils.SonarException: Error while reading Gendarme resu
lt file: C:\Users\a-jose.valdes\Documents\Visual Studio 2012\Projects\PoC\NAFT
.PoC.Implementation\.sonar\gendarme-report.xml
        at org.sonar.plugins.csharp.gendarme.results.GendarmeResultParser.parse(
GendarmeResultParser.java:105)
        at org.sonar.plugins.csharp.gendarme.GendarmeSensor.analyseResults(Genda
rmeSensor.java:226)
        at org.sonar.plugins.csharp.gendarme.GendarmeSensor.analyse(GendarmeSens
or.java:182)
        at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:7
2)
        at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:114)
        at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanConta
iner.java:142)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentCo
ntainer.java:92)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.
java:77)
        at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.j
ava:187)
        at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScan
Container.java:182)
        at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScan
Container.java:180)
        at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanCon
tainer.java:175)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentCo
ntainer.java:92)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.
java:77)
        at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:57)
        at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45)
        at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.ja
va:82)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentCo
ntainer.java:92)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.
java:77)
        at org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapCon
tainer.java:156)
        at org.sonar.batch.bootstrap.BootstrapContainer.doAfterStart(BootstrapCo
ntainer.java:144)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentCo
ntainer.java:92)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.
java:77)
        at org.sonar.batch.bootstrapper.Batch.startBatch(Batch.java:92)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:74)
        at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java
:45)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher
.java:87)
        ... 9 more
Caused by: com.ctc.wstx.exc.WstxIOException: Unexpected first character (char co
de 0xEF), not valid in xml document: could be mangled UTF-8 BOM marker. Make sur
e that the Reader uses correct encoding or pass an InputStream instead
        at com.ctc.wstx.io.ReaderBootstrapper.bootstrapInput(ReaderBootstrapper.
java:174)
        at com.ctc.wstx.stax.WstxInputFactory.doCreateSR(WstxInputFactory.java:5
31)
        at com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:585
)
        at com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:641
)
        at com.ctc.wstx.stax.WstxInputFactory.createXMLStreamReader(WstxInputFac
tory.java:323)
        at org.codehaus.staxmate.SMInputFactory.createStax2Reader(SMInputFactory
.java:234)
        at org.codehaus.staxmate.SMInputFactory.rootElementCursor(SMInputFactory
.java:337)
        at org.sonar.plugins.csharp.gendarme.results.GendarmeResultParser.parse(
GendarmeResultParser.java:100)
        ... 39 more
ERROR:
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
1
What command line are you using to trigger the Sonar runner?Nicole Calinoiu
I have executed sonar-runner under the root folder of my solution + sonar-project.properties file I also tried to use the sonar-runner -e and it throws a bunch of information. ERROR: Error during Sonar runner execution org.sonar.runner.impl.RunnerException: Unable to execute Sonar... Caused by: java.lang.IllegalStateException: You must define the following mandatory properties for 'Unknown': sonar.projectKey, sonar.projectName, sonar.project Version, sonar.sourcesJAVH
It really looks like the SonarQube Runner is not executed from the directory containing the sonar-project.properties file or that the sonar-project.properties file is misspelled. Could you please provide the full stack trace to know the answer?David RACODON - QA Consultant
Could you please provide the full command line that you are using to launch the Sonar runner?Nicole Calinoiu
I have added more information on the question, I'll hope this can help.JAVH

1 Answers

2
votes

Based on this message in the stack trace:

Caused by: com.ctc.wstx.exc.WstxIOException: Unexpected first character (char co
de 0xEF), not valid in xml document: could be mangled UTF-8 BOM marker. Make sur
e that the Reader uses correct encoding or pass an InputStream instead

I would suggest setting this property in either your sonar-project.properties file or in the sonar-runner.properties file:

sonar.sourceEncoding=UTF-8