How Do You Troubleshoot the Sonar-Scanner Problem “java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.ProjectLock”?

Problem scenario
You run sonar-scanner from the command line.  You receive an error such as this:  "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("

What should you do?

Possible solution #1
Is the file in the directory from which you ran sonar-scanner?  This command expects this file to be in that directory.

Possible solution #2
Does the user that ran sonar-scanner have permissions to read  This file needs to be readable.  You may need to use sudo before the sonar-scanner command or log in as a different user.

Possible solution #3
Does the file have a sonar.sources stanza?  If so is there a subdirectory that is at the same level as with the name assigned by the sonar.sources stanza?

If you see "sonar.sources=foobar", you would need a subdirectory named "foobar" in the directory with the file?

Leave a comment

Your email address will not be published. Required fields are marked *