1
votes

Below is my directory structure for SonarQube analysis.

enter image description here

I was using SonarQube 5.0 with C++ Community plugin version 0.9.4 and sonar-runner 2.4 with sonar.sources=../CheckoutDir1 mentioned in sonar-project.properties file. This was working like a charm.

Then I upgraded to SonarQube 5.1.2, keeping the C++ Community plugin, sonar-runner and sonar-project.properties file intact. Now sonar-runner fails with the following error:

14:18:17.531 INFO  - Base dir: D:\CheckoutDir2
14:18:17.531 INFO  - Working dir: D:\CheckoutDir2\.sonar
14:18:17.531 INFO  - Source paths: ../CheckoutDir1
.
.
.
.

    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:100)
    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:53)
Caused by: java.lang.NullPointerException
    at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:98)
    at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
    at sun.nio.fs.WindowsPath.parse(WindowsPath.java:94)
    at sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:255)
    at sun.nio.fs.AbstractPath.resolve(AbstractPath.java:53)
    at org.sonar.api.batch.fs.internal.DefaultInputFile.path(DefaultInputFile.java:72)
    at org.sonar.api.batch.fs.internal.DefaultInputFile.file(DefaultInputFile.java:64)
    at org.sonar.api.batch.fs.internal.PathPattern$RelativePathPattern.match(PathPattern.java:101)
    at org.sonar.batch.scan.filesystem.LanguageDetection.isCandidateForLanguage(LanguageDetection.java:124)
    at org.sonar.batch.scan.filesystem.LanguageDetection.language(LanguageDetection.java:97)
    at org.sonar.batch.scan.filesystem.InputFileBuilder.completeAndComputeMetadata(InputFileBuilder.java:100)
    at org.sonar.batch.scan.filesystem.FileIndexer$1.call(FileIndexer.java:157)
    at org.sonar.batch.scan.filesystem.FileIndexer$1.call(FileIndexer.java:154)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)

Strangely, the debug parameters -X, -e, -Dsonar.verbose=true in sonar-runner revealed no other information except java.lang.NullPointerException.

If I mention the absolute path for sonar.sources, the SonarQube analysis works fine.

Please suggest how to resolve this problem? Also, SonarQube 5.1.2 should clearly print the debug logs about not being able to locate the sonar.sources from a relative path.

1

1 Answers

0
votes

As I can see in the log that sonar is considering CheckoutDir2 as your base dir, Which is not correct,

you should set sonar.projectBaseDir=<AbsolutePath>/ProjectName/CheckoutDir1 and then sonar.sources=. so now even if sonar-project.properties file is not in the same directory as the source code, it will still work as if it was.