How to solve Sonar error: Unable to load component class org.sonar.scanner.scan.ProjectLock
Asked Answered
O

13

30

I have some issues while running Sonar on my netbeans' project. It's not working and i have the following error :

C:\Users\remy.fischer\Desktop\NetBeansProjects\NetBeansProjects\BinPacking\sonar-scanner-3.0.3.778-windows\bin>sonar-scanner -Dsonar.projectKey=..... -Dsonar.projectName=...
    INFO: Scanner configuration file: C:\Users\remy.fischer\Desktop\NetBeansProjects
    \NetBeansProjects\BinPacking\sonar-scanner-3.0.3.778-windows\bin\..\conf\sonar-s
    canner.properties
    INFO: Project root configuration file: NONE
    INFO: SonarQube Scanner 3.0.3.778
    INFO: Java 1.8.0_121 Oracle Corporation (64-bit)
    INFO: Windows 7 6.1 amd64
    INFO: User cache: C:\Users\remy.fischer\.sonar\cache
    can't open C:\Users\remy.fischer\Desktop\NetBeansProjects\NetBeansProjects\BinPa
    cking\sonar-scanner-3.0.3.778-windows\jre\lib\tzmappings.
    INFO: Load global settings
    INFO: Load global settings (done) | time=62ms
    INFO: User cache: C:\Users\remy.fischer\.sonar\cache
    INFO: Load plugins index
    INFO: Load plugins index (done) | time=0ms
    INFO: SonarQube server 6.4.0
    INFO: Default locale: "fr_FR", source code encoding: "UTF-8"
    INFO: Process project properties
    INFO: ------------------------------------------------------------------------
    INFO: EXECUTION FAILURE
    INFO: ------------------------------------------------------------------------
    INFO: Total time: 1.248s
    INFO: Final Memory: 39M/178M
    INFO: ------------------------------------------------------------------------
    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:71)
            at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:678)
            at org.sonar.core.platform.ComponentContainer.getComponentByType(ComponentContainer.java:283)
            at org.sonar.scanner.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:110)
            at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
            at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:129)
            at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47)
            at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:86)
            at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:144)
            at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:129)
            at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:118)
            at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:117)
            at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:63)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)
            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:233)
            at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
            at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:123)
            at org.sonarsource.scanner.cli.Main.execute(Main.java:77)
            at org.sonarsource.scanner.cli.Main.main(Main.java:61)
    Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.api.batch.bootstrap.ProjectReactor
            at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:71)
            at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
            at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
            at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
            at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
            at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309)
            at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335)
            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:69)
            ... 23 more
    emy.fischerDesktopNetBeansProjectsNetBeansProjectsBinPackingsrcbinpacking
            at sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
            at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
            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 java.nio.file.Paths.get(Paths.java:84)
            at org.sonar.scanner.scan.ProjectReactorBuilder.resolvePath(ProjectReactorBuilder.java:395)
            at org.sonar.scanner.scan.ProjectReactorBuilder.checkExistenceOfPaths(ProjectReactorBuilder.java:385)
            at org.sonar.scanner.scan.ProjectReactorBuilder.cleanAndCheckModuleProperties(ProjectReactorBuilder.java:368)
            at org.sonar.scanner.scan.ProjectReactorBuilder.cleanAndCheckProjectDefinitions(ProjectReactorBuilder.java:334)
            at org.sonar.scanner.scan.ProjectReactorBuilder.execute(ProjectReactorBuilder.java:126)
            at org.sonar.scanner.scan.MutableProjectReactorProvider.provide(MutableProjectReactorProvider.java:30)
            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.picocontainer.injectors.MethodInjector.invokeMethod(MethodInjector.java:129)
            at org.picocontainer.injectors.MethodInjector.access$000(MethodInjector.java:39)
            at org.picocontainer.injectors.MethodInjector$2.run(MethodInjector.java:113)
            at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
            at org.picocontainer.injectors.MethodInjector.decorateComponentInstance(MethodInjector.java:120)
            at org.picocontainer.injectors.CompositeInjector.decorateComponentInstance(CompositeInjector.java:58)
            at org.picocontainer.injectors.Reinjector.reinject(Reinjector.java:142)
            at org.picocontainer.injectors.ProviderAdapter.getComponentInstance(ProviderAdapter.java:96)
            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:69)
            ... 37 more
    ERROR:
    ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.

    C:\Users\remy.fischer\Desktop\NetBeansProjects\NetBeansProjects\BinPacking\sonar-scanner-3.0.3.778-windows\bin>

I don't know what to do, I've try many things that i've seen here but nothing is working unfortunately..

Omdurman answered 21/6, 2017 at 7:30 Comment(2)
Stack may be the wrong forum, seems a bug to me. Its at least a bug in saying what the issue is. Though I am not able to see where you could report an issue. Could you add version 6.4 somewhere and perhaps try a previous version. I am going through the same exact issueOxyhydrogen
I'm currently having the same issue as well. Did any of you manage to figure it out?Maurili
B
17

I've got this too, but I was using gradle to run sonar for sonarcloud.io, once I turned on --stacktrace and --debug it was clear from the logs I was getting this error because my credentials did not get recognized by the sonar server. I've double checked them and after changing to the correct credentials all went fine.

So besides trying to run it with -X as suggested to get more info, I'd suggest you also try to double check your credentials.

Bollworm answered 28/11, 2017 at 20:38 Comment(1)
I found the wrong password. ThanksLaundrywoman
T
8

I had the same exact error when trying to trigger sonar analysis from within Jenkins, after houres of searching, i figured out that the problem was related to path defintion.

In your sonar-project.properties file or in SonarQube configuration section within your project configuration section, make sure that the property sonar.sources defines a path using forward slashes (/)

the property must be defined like this : sonar.sources=D:/software/jenkins/JenkinsHome/workspace/test_jenkins

and NOT like this : sonar.sources=D:\software\jenkins\JenkinsHome\workspace\test_jenkins

Tadashi answered 3/7, 2018 at 10:50 Comment(1)
Thank you, that was it.Stoffel
G
3

I had the same problem while I was trying to configure Pull Request checks for Sonarqube on Github. Credentials were correct in my case but I was giving sonar.github.repository=myorg:myrepository and it was causing this error. I fixed it by changing it to sonar.github.repository=myorg/myrepository

Maybe it can help someone...

Grandnephew answered 30/5, 2018 at 10:10 Comment(0)
F
2

This may be because of owner of project directory and owner of sonar-scanner is different,try granting 755 to project directory, so that sonar-scanner can access this

Flu answered 19/7, 2019 at 6:57 Comment(0)
S
1

For us, the problem was that an Interface accidentially had a hat above the I in the filename, the file was named ÎFoo

Sickener answered 17/5, 2020 at 18:35 Comment(0)
M
1

The best way to solve this problem is to run using --stacktrace. This will give the complete log, and you can easily identify the issue. In my case, the issue as because the module was not correctly defined.

Meander answered 13/7, 2021 at 7:11 Comment(0)
U
0

I encountered this issue too, but I'm able to solve by removing the external SonarQube plugin downloaded from marketplace. I'm not sure whether it can solve your problem, but hope it could help you.

Unemployment answered 9/10, 2019 at 2:50 Comment(0)
O
0

I had the same issue. If you run SonaeQube in Docker, try to remove volumes that bind with SonarQube docker volume rm <some SonarQube volume>. In case when you use only SonarQube in docker and other images is not important or not exist you are able to use (warning: that command deleting all volumes on your machine) docker volume prune. Also you can use flag --remove-orphans when you create docker container, example: docker-compose up -d --remove-orphans. This tag as say documenttation:

Remove containers for services not defined in the Compose file.

This issue can arise if you switched SonarQube version without clearing volumes

Overcast answered 17/7, 2021 at 15:24 Comment(0)
P
0

In case this helps anybody, creating the <sonar-scanner-dir>/conf/sonar-scanner.properties file fixed it for me.

It actually worked in the first place, but broke when moved it all to a docker image - I forgot to move the <sonar-scanner-dir>/conf/sonar-scanner.properties file in.

See post number six here: You must define the following mandatory properties for 'Unknown': sonar.projectKey - Get help / SonarQube - SonarSource Community

BTW: There error message I got also contains the following, which is not included in OP's post:

ERROR: You must define the following mandatory properties for ‘Unknown’: sonar.projectKey

Payer answered 19/7, 2021 at 20:16 Comment(0)
M
0

I faced the same issue. I restarted the SonarQube server and the sonar-scanner command worked.

Minutiae answered 26/1, 2022 at 11:22 Comment(0)
B
0

If you face this error in Node.

  1. Remove package-lock.json
  2. Remove node_modules
  • Run npm install
  • Run sonar-scanner
Barchan answered 20/4, 2022 at 9:21 Comment(0)
H
0

Faced this issue. For me the path given in sonar.sources property was wrong.

Although the error says the issue is with loading class, the root cause is mostly some issue with the sonar properties.

Hackney answered 4/1, 2023 at 19:35 Comment(0)
D
0

For me, the problem was that I had an erroneous comma in my sonar-project.properties: sonar.sourceEncoding = UTF-8,

Darlenadarlene answered 8/8, 2023 at 20:27 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.