nullpointerexception in BlameGenerator when executing sonar-runner

2.3k views Asked by At

When i execute sonar-runner to analyze my project i get the following stacktrace:

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.IllegalStateException: Unable to blame file client/src/main/java/idainfront/ekn/client/util/ClientFileUtil.java
    at org.sonar.plugins.scm.git.JGitBlameCommand.blame(JGitBlameCommand.java:128)
    at org.sonar.plugins.scm.git.JGitBlameCommand.access$000(JGitBlameCommand.java:45)
    at org.sonar.plugins.scm.git.JGitBlameCommand$1.call(JGitBlameCommand.java:113)
    at org.sonar.plugins.scm.git.JGitBlameCommand$1.call(JGitBlameCommand.java:110)
    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:745)
Caused by: java.lang.NullPointerException
    at org.eclipse.jgit.blame.BlameGenerator.getSourceStart(BlameGenerator.java:871)
    at org.eclipse.jgit.blame.BlameResult.loadFrom(BlameResult.java:338)
    at org.eclipse.jgit.blame.BlameResult.computeAll(BlameResult.java:240)
    at org.eclipse.jgit.blame.BlameGenerator.computeBlameResult(BlameGenerator.java:451)
    at org.eclipse.jgit.api.BlameCommand.call(BlameCommand.java:231)
    at org.sonar.plugins.scm.git.JGitBlameCommand.blame(JGitBlameCommand.java:123)
    ... 7 more

Version: sonar-runner 2.4, sonar 5.1.1

When I exclude the file everything works fine:

sonar.exclusions=**/src/main/java/idainfront/ekn/client/util/ClientFileUtil.java

Is this a known bug or is there a better workaround?

1

There are 1 answers

0
ryzhman On

I had a similar issue, but the root of the problem was that by default my Sonar.maven.plugin config used GIT SCM, meanwhile, the project was built on SVN. Thus, I had to set it explicitly with -Dsonar.scm.provider=svn in Maven