Sonnar Scanner in CI/CD pipeline Throws: java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.ProjectLock

Dear all,

We are using SonarQube community edition 7.7 in conjunction to our Atlassian Bamboo CI/CD pipeline. We created a plan to checkout out code and subsequently scan it in sonar-scanner-3.3.0.1492-windows.

The plan was working in PROD with out issues then suddenly we started getting the error bellow:

|23-Apr-2019 13:08:45|java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.ProjectLock|

I found some posts that talked about possibly rebuilding the index in SonarQube and I tried, but it did not work. Now I am running out of options considering that in our test environment we do not see this behavior nor have I been able to spot any difference with the SonarQube configuration, scanner CLI or bamboo install and plans.

Does anyone have any idea what would be causing this and has anyone else seen this ?

Thanks in advance for any guidance
max

23-Apr-2019 13:08:42 13:08:42.567 INFO: SonarQube server 7.7.0
23-Apr-2019 13:08:42 13:08:42.568 INFO: Default locale: “en_US”, source code encoding: “UTF-8”
23-Apr-2019 13:08:42 13:08:42.569 DEBUG: Work directory: D:\Atlassian\ApplicationData\BAMBOO\xml-data\build-dir\MT-DEV-JOB1.scannerwork
23-Apr-2019 13:08:42 13:08:42.570 DEBUG: Execution execute
23-Apr-2019 13:08:43 13:08:43.123 INFO: Load global settings
23-Apr-2019 13:08:43 13:08:43.780 DEBUG: GET 200 https://XXXXXX.com/SONARQUBE/api/settings/values.protobuf
23-Apr-2019 13:08:43 13:08:43.822 INFO: Load global settings (done)
23-Apr-2019 13:08:43 13:08:43.826 INFO: Server id: XOXOXOXOX-AWKcUr9QCnvqFhGICWuz
23-Apr-2019 13:08:43 13:08:43.847 INFO: User cache: C:\Windows\system32\config\systemprofile.sonar\cache
23-Apr-2019 13:08:43 13:08:43.853 INFO: Load/download plugins
23-Apr-2019 13:08:43 13:08:43.853 INFO: Load plugins index
23-Apr-2019 13:08:44 13:08:44.414 DEBUG: GET 200 https://XXXXX.com/SONARQUBE/api/plugins/installed
23-Apr-2019 13:08:44 13:08:44.482 INFO: Load plugins index (done)
23-Apr-2019 13:08:44 13:08:44.550 INFO: Load/download plugins (done)
23-Apr-2019 13:08:44 13:08:44.664 DEBUG: Plugins:
23-Apr-2019 13:08:44 13:08:44.664 DEBUG: * Dependency-Check 1.2.2-SNAPSHOT (dependencycheck)
23-Apr-2019 13:08:44 13:08:44.665 DEBUG: * SonarPython 1.13.0.2922 (python)
23-Apr-2019 13:08:44 13:08:44.665 DEBUG: * SonarCSS 1.0.3.724 (cssfamily)
23-Apr-2019 13:08:44 13:08:44.665 DEBUG: * JaCoCo 1.0.1.143 (jacoco)
23-Apr-2019 13:08:44 13:08:44.665 DEBUG: * SonarGo 1.1.0.1612 (go)
23-Apr-2019 13:08:44 13:08:44.665 DEBUG: * SonarKotlin 1.5.0.315 (kotlin)
23-Apr-2019 13:08:44 13:08:44.665 DEBUG: * Svn 1.9.0.1295 (scmsvn)
23-Apr-2019 13:08:44 13:08:44.665 DEBUG: * SonarJS 5.1.1.7506 (javascript)
23-Apr-2019 13:08:44 13:08:44.666 DEBUG: * SonarRuby 1.5.0.315 (ruby)
23-Apr-2019 13:08:44 13:08:44.666 DEBUG: * SonarScala 1.5.0.315 (sonarscala)
23-Apr-2019 13:08:44 13:08:44.666 DEBUG: * SonarC# 7.11.0.8083 (csharp)
23-Apr-2019 13:08:44 13:08:44.666 DEBUG: * SonarJava 5.11.0.17289 (java)
23-Apr-2019 13:08:44 13:08:44.666 DEBUG: * LDAP 2.2.0.608 (ldap)
23-Apr-2019 13:08:44 13:08:44.666 DEBUG: * SonarHTML 3.1.0.1615 (web)
23-Apr-2019 13:08:44 13:08:44.667 DEBUG: * Git 1.8.0.1574 (scmgit)
23-Apr-2019 13:08:44 13:08:44.667 DEBUG: * SonarFlex 2.4.0.1222 (flex)
23-Apr-2019 13:08:44 13:08:44.667 DEBUG: * SonarXML 2.0.1.2020 (xml)
23-Apr-2019 13:08:44 13:08:44.667 DEBUG: * SonarPHP 3.0.0.4537 (php)
23-Apr-2019 13:08:44 13:08:44.667 DEBUG: * SonarTS 1.9.0.3766 (typescript)
23-Apr-2019 13:08:44 13:08:44.667 DEBUG: * SonarVB 7.11.0.8083 (vbnet)
23-Apr-2019 13:08:45 13:08:45.592 INFO: Process project properties
23-Apr-2019 13:08:45 13:08:45.605 DEBUG: Process project properties (done)
23-Apr-2019 13:08:45 13:08:45.605 INFO: Execute project builders
23-Apr-2019 13:08:45 13:08:45.606 DEBUG: Execute project builder: org.sonar.plugins.csharp.CSharpGlobalProtobufFileProcessor
23-Apr-2019 13:08:45 13:08:45.610 DEBUG: Execute project builder: org.sonar.plugins.vbnet.VbNetGlobalProtobufFileProcessor
23-Apr-2019 13:08:45 13:08:45.613 INFO: Execute project builders (done)
23-Apr-2019 13:08:45 13:08:45.623 INFO: ------------------------------------------------------------------------
23-Apr-2019 13:08:45 13:08:45.623 INFO: EXECUTION FAILURE
23-Apr-2019 13:08:45 13:08:45.623 INFO: ------------------------------------------------------------------------
23-Apr-2019 13:08:45 13:08:45.623 INFO: Total time: 4.079s
23-Apr-2019 13:08:45 13:08:45.729 INFO: Final Memory: 10M/264M
23-Apr-2019 13:08:45 13:08:45.729 INFO: ------------------------------------------------------------------------
23-Apr-2019 13:08:45 13:08:45.729 ERROR: Error during SonarQube Scanner execution
23-Apr-2019 13:08:45 java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.ProjectLock
23-Apr-2019 13:08:45 at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:65)
23-Apr-2019 13:08:45 at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:678)
23-Apr-2019 13:08:45 at org.sonar.core.platform.ComponentContainer.getComponentByType(ComponentContainer.java:281)
23-Apr-2019 13:08:45 at org.sonar.scanner.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:136)
23-Apr-2019 13:08:45 at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:134)
23-Apr-2019 13:08:45 at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
23-Apr-2019 13:08:45 at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:128)
23-Apr-2019 13:08:45 at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
23-Apr-2019 13:08:45 at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
23-Apr-2019 13:08:45 at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:73)
23-Apr-2019 13:08:45 at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
23-Apr-2019 13:08:45 at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
23-Apr-2019 13:08:45 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
23-Apr-2019 13:08:45 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
23-Apr-2019 13:08:45 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
23-Apr-2019 13:08:45 at java.lang.reflect.Method.invoke(Method.java:498)
23-Apr-2019 13:08:45 at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
23-Apr-2019 13:08:45 at com.sun.proxy.$Proxy0.execute(Unknown Source)
23-Apr-2019 13:08:45 at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:185)
23-Apr-2019 13:08:45 at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:137)
23-Apr-2019 13:08:45 at org.sonarsource.scanner.cli.Main.execute(Main.java:111)
23-Apr-2019 13:08:45 at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
23-Apr-2019 13:08:45 at org.sonarsource.scanner.cli.Main.main(Main.java:61)
23-Apr-2019 13:08:45 Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.api.batch.fs.internal.DefaultInputProject
23-Apr-2019 13:08:45 at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:65)
23-Apr-2019 13:08:45 at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
23-Apr-2019 13:08:45 at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
23-Apr-2019 13:08:45 at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
23-Apr-2019 13:08:45 at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
23-Apr-2019 13:08:45 at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309)
23-Apr-2019 13:08:45 at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335)
23-Apr-2019 13:08:45 at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
23-Apr-2019 13:08:45 at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
23-Apr-2019 13:08:45 at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
23-Apr-2019 13:08:45 at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
23-Apr-2019 13:08:45 at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
23-Apr-2019 13:08:45 at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
23-Apr-2019 13:08:45 at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
23-Apr-2019 13:08:45 at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:63)
23-Apr-2019 13:08:45 … 22 more
23-Apr-2019 13:08:45 Caused by: Validation of project reactor failed:
23-Apr-2019 13:08:45 o To use the property “sonar.branch.name”, the branch plugin is required but not installed. See the documentation of branch support: https://redirect.sonarsource.com/doc/branches.html.
23-Apr-2019 13:08:45 Failing task since return code of [D:\MyPrograms\sonar-scanner-3.3.0.1492-windows\bin\sonar-scanner.bat -X -Dsonar.host.url=https://XXXXXXXX.com/SONARQUBE -Dsonar.login=****** -Dsonar.password=****** -Dsonar.branch.name=dev] was 1 while expected 0
23-Apr-2019 13:08:45 SONAR4BAMBOO: was not able to find a SonarQube result URL

Hi,

This message indicates that you are specifying the branch name. The analysis of branches is a feature that is not available in the community edition of SonarQube.

Thank you for your quick reply.

This odd I am really confused we have a bunch of repos with branches against SonarQube community edition, They have been running for close to a year going to different branches just for scanning not comparison. And now i am wondering how are they actually working - is it a fluke?

My latest plan worked for a day in prod then it started throwing exception, but the DEV environment version is still working?.

Could it be a configuration setting? any other suggestions?

Thanks
max

My only guess is that maybe you have been using the old branch parameter, sonar.branch?

With that parameter, an entire new project is created in SonarQube for every branch, so you don’t really benefit from the features introduced with the new branch analysis.

Duarte,

Thanks again for the suggestion after a little bit of digging the issue appears to be related to the Sonar plugin that we are using within bamboo. Existing plans will keep on working but if I create a new one or make a modification through the GUI then after I save the “legacybranch” setting is set from “TRUE” to “” probably explaining why the plans begins to fail. I have contacted Mibex the vendor of the plugin and they are looking into it.

Thanks again
max

Has this projectlock issue been resolved? I am still getting this error stopping the works.

Thanks

Hello,
Could you please post your logs?
As you can see above, the “ProjectLock” is usually not the problem.

java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.ProjectLock
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:65)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:678)
at org.sonar.core.platform.ComponentContainer.getComponentByType(ComponentContainer.java:281)
at org.sonar.scanner.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:153)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:134)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:73)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
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:185)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:137)
at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
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: Unable to load component class org.sonar.api.batch.fs.internal.DefaultInputProject


aused by: You must define the following mandatory properties for ‘Unknown’: sonar.projectKey
Build step ‘Execute shell’ marked build as failure
Finished: FAILURE