ERROR: Error during SonarQube Scanner execution java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.ProjectLock

SonarQube server 7.0.0
SonarQube Scanner 3.2.0.1227
sonar-scan still working using Bamboo, but now shifting to Jenkins 2 (newtmitch/sonar-scanner:3.2.0)
Matched version of scanner and using all the same config wherever possible.
I have seen similar tickets that mention credential issues, but if those were wrong it would not get so far. I had to strip “http” out of the log to prevent the number of links causing issues with posting.
You can see that I used -X verbose mode.

That project key (com.example.mint:mint-adserver-business-service) in Sonar already exists - could this be a problem?

+ /usr/local/bin/sonar-scanner -X -Dsonar.host.url= s://sonarqube.example.com -Dsonar.projectVersion=1.0.14 -Dsonar.projectKey=com.example.mint:mint-adserver-business-service -Dsonar.projectName=mint-adserver-business-service -Dsonar.sources=. -Dsonar.exclusions=**/model/**.*,**/dto/**.*,**/aop/**.*.,**/aop/**,**/model/**,**/bamboo/**.*,**/bamboo/** -Dsonar.coverage.exclusions=**/model/**.*,**/dto/**.*,**/aop/**.*.,**/aop/**,**/model/**,**/bamboo/**.*,**/bamboo/**,**/test/**.*,**/test/** -Dsonar.junit.reportPaths=target/surefire-reports -Dsonar.java.binaries=target/classes -Dsonar.java.coveragePlugin=jacoco -Dsonar.java.test.binaries=target/test-classes -Dsonar.java.test.libraries=target/lib/*.jar -Dsonar.login=800b3687ad0a4438f836e5c0135aab9e8bd20742 -Dsonar.jacoco.reportPaths=target/jacoco.exec
06:15:06.117 INFO: Scanner configuration file: /usr/lib/sonar-scanner/conf/sonar-scanner.properties
06:15:06.124 INFO: Project root configuration file: NONE
06:15:06.164 INFO: SonarQube Scanner 3.2.0.1227
06:15:06.164 INFO: Java 1.8.0_121 Oracle Corporation (64-bit)
06:15:06.164 INFO: Linux 4.14.123-86.109.amzn1.x86_64 amd64
06:15:06.339 DEBUG: keyStore is : 
06:15:06.339 DEBUG: keyStore type is : jks
06:15:06.339 DEBUG: keyStore provider is : 
06:15:06.339 DEBUG: init keystore
06:15:06.340 DEBUG: init keymanager of type SunX509
06:15:06.417 DEBUG: Create: ?/.sonar/cache
06:15:06.418 INFO: User cache: ?/.sonar/cache
06:15:06.418 DEBUG: Create: ?/.sonar/cache/_tmp
06:15:06.420 DEBUG: Extract sonar-scanner-api-batch in temp...
06:15:06.429 DEBUG: Get bootstrap index...
06:15:06.429 DEBUG: Download:  s://sonarqube.example.com/batch/index
06:15:06.658 DEBUG: Get bootstrap completed
06:15:06.672 DEBUG: Download  s://sonarqube.example.com/batch/file?name=sonar-scanner-engine-shaded-7.0.jar to /home/jenkins/workspace/publish-trail-pattern-ui_develop/?/.sonar/cache/_tmp/fileCache3700484929972363549.tmp
06:15:07.408 DEBUG: Create isolated classloader...
06:15:07.419 DEBUG: Start temp cleaning...
06:15:07.425 DEBUG: Temp cleaning done
06:15:07.425 DEBUG: Execution getVersion
06:15:07.428 INFO: SonarQube server 7.0.0
06:15:07.429 INFO: Default locale: "en", source code encoding: "UTF-8" (analysis is platform dependent)
06:15:07.429 DEBUG: Work directory: /usr/src/.scannerwork
06:15:07.430 DEBUG: Execution execute
06:15:07.598 INFO: Publish mode
06:15:07.684 INFO: Load global settings
06:15:07.867 DEBUG: GET 200  s://sonarqube.example.com/api/settings/values.protobuf | time=177ms
06:15:07.910 INFO: Load global settings (done) | time=226ms
06:15:07.917 INFO: Server id: AWSJ1ersgfqfwaI7jAjY
06:15:07.923 WARN: Property 'sonar.jdbc.url' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.
06:15:07.925 INFO: User cache: /home/jenkins/workspace/publish-trail-pattern-ui_develop/?/.sonar/cache
06:15:08.084 INFO: Load plugins index
06:15:08.108 DEBUG: GET 200  s://sonarqube.example.com/api/plugins/installed | time=24ms
06:15:08.132 INFO: Load plugins index (done) | time=48ms
06:15:08.132 INFO: Load/download plugins
06:15:08.133 DEBUG: Download plugin 'checkstyle-sonar-plugin-4.10.jar' to '?/.sonar/cache/_tmp/fileCache6924696370518197593.tmp'
06:15:08.167 DEBUG: GET 200  s://sonarqube.example.com/deploy/plugins/checkstyle/checkstyle-sonar-plugin-4.10.jar | time=34ms
06:15:08.934 DEBUG: Download plugin 'qualinsight-sonarqube-smell-plugin-4.0.0.jar' to '?/.sonar/cache/_tmp/fileCache7533425092054650815.tmp'
06:15:08.952 DEBUG: GET 200  s://sonarqube.example.com/deploy/plugins/smells/qualinsight-sonarqube-smell-plugin-4.0.0.jar | time=18ms
06:15:09.049 DEBUG: Download plugin 'sonar-findbugs-plugin-3.7.0.jar' to '?/.sonar/cache/_tmp/fileCache6292784645066601717.tmp'
06:15:09.066 DEBUG: GET 200  s://sonarqube.example.com/deploy/plugins/findbugs/sonar-findbugs-plugin-3.7.0.jar | time=17ms
06:15:09.319 DEBUG: Download plugin 'sonar-groovy-plugin-1.5.jar' to '?/.sonar/cache/_tmp/fileCache4991614976507224111.tmp'
06:15:09.337 DEBUG: GET 200  s://sonarqube.example.com/deploy/plugins/groovy/sonar-groovy-plugin-1.5.jar | time=18ms
06:15:09.653 DEBUG: Download plugin 'sonar-ldap-plugin-2.2.0.608.jar' to '?/.sonar/cache/_tmp/fileCache1359433887938686744.tmp'
06:15:09.672 DEBUG: GET 200  s://sonarqube.example.com/deploy/plugins/ldap/sonar-ldap-plugin-2.2.0.608.jar | time=19ms
06:15:09.680 DEBUG: Download plugin 'sonar-pmd-plugin-2.6.jar' to '?/.sonar/cache/_tmp/fileCache618800358600643244.tmp'
06:15:09.699 DEBUG: GET 200  s://sonarqube.example.com/deploy/plugins/pmd/sonar-pmd-plugin-2.6.jar | time=19ms
06:15:09.830 DEBUG: Download plugin 'sonar-rci-plugin-1.0.1.jar' to '?/.sonar/cache/_tmp/fileCache8680684733724473456.tmp'
06:15:09.865 DEBUG: GET 200  s://sonarqube.example.com/deploy/plugins/rci/sonar-rci-plugin-1.0.1.jar | time=35ms
06:15:09.866 DEBUG: Download plugin 'sonar-javascript-plugin-4.1.0.6085.jar' to '?/.sonar/cache/_tmp/fileCache3746672447011809913.tmp'
06:15:09.883 DEBUG: GET 200  s://sonarqube.example.com/deploy/plugins/javascript/sonar-javascript-plugin-4.1.0.6085.jar | time=17ms
06:15:09.972 DEBUG: Download plugin 'sonar-java-plugin-5.5.0.14655.jar' to '?/.sonar/cache/_tmp/fileCache7804779871574055688.tmp'
06:15:09.990 DEBUG: GET 200  s://sonarqube.example.com/deploy/plugins/java/sonar-java-plugin-5.5.0.14655.jar | time=18ms
06:15:10.208 DEBUG: Download plugin 'sonar-web-plugin-2.6.0.1053.jar' to '?/.sonar/cache/_tmp/fileCache4823763734434871447.tmp'
06:15:10.227 DEBUG: GET 200  s://sonarqube.example.com/deploy/plugins/web/sonar-web-plugin-2.6.0.1053.jar | time=19ms
06:15:10.273 DEBUG: Download plugin 'sonar-sonargraph-integration-2.1.5.jar' to '?/.sonar/cache/_tmp/fileCache2668534467935901001.tmp'
06:15:10.291 DEBUG: GET 200  s://sonarqube.example.com/deploy/plugins/sonargraphintegration/sonar-sonargraph-integration-2.1.5.jar | time=18ms
06:15:10.316 DEBUG: Download plugin 'sonar-jdepend-plugin-1.1.1.jar' to '?/.sonar/cache/_tmp/fileCache8125415333108840635.tmp'
06:15:10.334 DEBUG: GET 200  s://sonarqube.example.com/deploy/plugins/jdepend/sonar-jdepend-plugin-1.1.1.jar | time=18ms
06:15:10.337 INFO: Load/download plugins (done) | time=2205ms
06:15:10.552 DEBUG: API compatibility mode is enabled on plugin PMD [pmd] (built with API lower than 5.2)
06:15:10.690 DEBUG: Plugins:
06:15:10.690 DEBUG:   * Code Smells 4.0.0 (smells)
06:15:10.691 DEBUG:   * PMD 2.6 (pmd)
06:15:10.691 DEBUG:   * jDepend 1.1.1 (jdepend)
06:15:10.691 DEBUG:   * SonarJS 4.1.0.6085 (javascript)
06:15:10.691 DEBUG:   * Findbugs 3.7.0 (findbugs)
06:15:10.691 DEBUG:   * Groovy 1.5 (groovy)
06:15:10.691 DEBUG:   * SonarJava 5.5.0.14655 (java)
06:15:10.691 DEBUG:   * Sonargraph Integration 2.1.5 (sonargraphintegration)
06:15:10.691 DEBUG:   * LDAP 2.2.0.608 (ldap)
06:15:10.692 DEBUG:   * SonarWeb 2.6.0.1053 (web)
06:15:10.692 DEBUG:   * Rules Compliance Index (RCI) 1.0.1 (rci)
06:15:10.692 DEBUG:   * Checkstyle 4.10 (checkstyle)
06:15:11.202 INFO: Sonargraph Integration: Custom metrics file '?/.sonargraphintegration/metrics.properties' not found
06:15:11.204 INFO: Sonargraph Integration: Created 50 predefined and 0 custom metric(s)
06:15:11.228 INFO: Process project properties
06:15:11.233 DEBUG: Process project properties (done) | time=5ms
06:15:11.295 INFO: ------------------------------------------------------------------------
06:15:11.295 INFO: EXECUTION FAILURE
06:15:11.295 INFO: ------------------------------------------------------------------------
06:15:11.295 INFO: Total time: 5.227s
06:15:11.327 INFO: Final Memory: 15M/350M
06:15:11.327 INFO: ------------------------------------------------------------------------
06:15:11.327 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(ComponentContainer.java:64)
	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:678)
	at org.sonar.core.platform.ComponentContainer.getComponentByType(ComponentContainer.java:265)
	at org.sonar.scanner.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:118)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:133)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
	at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
	at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:84)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
	at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:121)
	at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:71)
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at com.sun.proxy.$Proxy0.execute(Unknown Source)
	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:171)
	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:128)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:111)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
	at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.lang.IllegalStateException: Failed to create work directory
	at org.sonar.scanner.scan.ProjectLock.<init>(ProjectLock.java:41)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.picocontainer.injectors.AbstractInjector.newInstance(AbstractInjector.java:145)
	at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:342)
	at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
	at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
	at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
	at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
	at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
	at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
	at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:62)
	... 24 more
Caused by: java.nio.file.AccessDeniedException: /usr/src/.scannerwork
	at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
	at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:384)
	at java.nio.file.Files.createDirectory(Files.java:674)
	at java.nio.file.Files.createAndCheckIsDirectory(Files.java:781)
	at java.nio.file.Files.createDirectories(Files.java:767)
	at org.sonar.scanner.scan.ProjectLock.<init>(ProjectLock.java:38)
	... 38 more
[Pipeline] }

Hi,

Your problem is actually pretty simple:

06:15:11.327 ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.ProjectLock
...
Caused by: java.lang.IllegalStateException: Failed to create work directory
...
Caused by: java.nio.file.AccessDeniedException: /usr/src/.scannerwork

This boils down to permissions.

 
HTH,
Ann

Ah yes, I paid more attention to earlier in the log than the bottom :frowning:

So run the Docker image as root in Jenkins 2 and that has resolved it. Many, many thanks Ann!

docker.image(‘newtmitch/sonar-scanner:3.2.0’).inside(’-v /var/run/docker.sock:/var/run/docker.sock --entrypoint="" -u 0:0’) {