Code Analysis Failing

Hi,

I am suddenly getting failures in my build on the Code Analysis step. The error is below:

2019-02-14T01:25:32.7213146Z INFO: SCM collecting changed files in the branch
2019-02-14T01:25:36.0686153Z INFO: ------------------------------------------------------------------------
2019-02-14T01:25:36.0687050Z INFO: EXECUTION FAILURE
2019-02-14T01:25:36.0687538Z INFO: ------------------------------------------------------------------------
2019-02-14T01:25:36.0689337Z INFO: Total time: 47.787s
2019-02-14T01:25:36.1932159Z ##[error]ERROR: Error during SonarQube Scanner execution
ERROR: Unable to load component class org.sonar.scanner.scan.filesystem.ProjectFileIndexer
ERROR: Caused by: Unable to load component class org.sonar.scanner.scan.filesystem.FileIndexer
ERROR: Caused by: Unable to load component class org.sonar.scanner.scan.filesystem.MetadataGenerator
2019-02-14T01:25:36.1932740Z ERROR: Error during SonarQube Scanner execution
2019-02-14T01:25:36.1932984Z ERROR: Unable to load component class org.sonar.scanner.scan.filesystem.ProjectFileIndexer
2019-02-14T01:25:36.1933316Z ERROR: Caused by: Unable to load component class org.sonar.scanner.scan.filesystem.FileIndexer
2019-02-14T01:25:36.1933668Z ERROR: Caused by: Unable to load component class org.sonar.scanner.scan.filesystem.MetadataGenerator
2019-02-14T01:25:36.1933747Z INFO: Final Memory: 26M/345M
2019-02-14T01:25:36.1933805Z INFO: ------------------------------------------------------------------------
2019-02-14T01:25:36.1933994Z ##[error]ERROR: Caused by: Unable to load component class org.sonar.scanner.scan.filesystem.StatusDetection
ERROR: Caused by: Unable to load component class org.sonar.scanner.scm.ScmChangedFiles
ERROR:
2019-02-14T01:25:36.1934189Z ERROR: Caused by: Unable to load component class org.sonar.scanner.scan.filesystem.StatusDetection
2019-02-14T01:25:36.1934256Z ERROR: Caused by: Unable to load component class org.sonar.scanner.scm.ScmChangedFiles
2019-02-14T01:25:36.1934308Z ERROR:
2019-02-14T01:25:36.3762215Z ##[error]The SonarQube Scanner did not complete successfully
2019-02-14T01:25:36.3763904Z The SonarQube Scanner did not complete successfully
2019-02-14T01:25:36.3826053Z 01:25:36.364 Creating a summary markdown file...
2019-02-14T01:25:36.3830601Z ##[error]01:25:36.38 Post-processing failed. Exit code: 1
2019-02-14T01:25:36.3922701Z 01:25:36.38 Post-processing failed. Exit code: 1
2019-02-14T01:25:36.5454668Z ##[error]D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.5.1\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe failed with return code: 1

Please add:

  • list of the installed plugins on SonarQube server
  • version of the SonarQube server
  • version of the used SonarSource Scanner

It seems to me that you have incompatible plugins with the server or the scanner.

1 Like

@agabrys

Hi - We are using SonarCloud - so I think the answers are below:

  • None - we use SonarCloud
  • No idea - We use SonarCloud
  • We are using the Azure Devops task

Hi Greg,

That’s strange, the stacktrace seems truncated. Could you please run the build with debug variable set to true, maybe it will reveal the root cause.
I’m interested by what should come after:

2019-02-14T01:25:36.1934256Z ERROR: Caused by: Unable to load component class org.sonar.scanner.scm.ScmChangedFiles
2019-02-14T01:25:36.1934308Z ERROR:

Anyway the error seems related to our integration with SCM (you are using Git I presume).

Hi, We’ve recently encountered the same issue, and may be able to provide some further details:
We’ve just upgraded our SQ version, we’re now using 7.6 Developer.
The issue has come to light as it’s triggered during branch analysis which we couldn’t use prior to getting a Developer license.

When running an Azure Devops build pipeline, we have a maven step using validate as the goal, and are calling for sonarqube to run as part of this build step.

Greater detail from the last couple of errors in the stack trace:

Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scm.ScmChangedFiles
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:65)
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:63)
... 85 more

Caused by: java.lang.NullPointerException
at org.eclipse.jgit.lib.ObjectIdOwnerMap.get(ObjectIdOwnerMap.java:138)
at org.eclipse.jgit.revwalk.RevWalk.parseAny(RevWalk.java:888)
at org.eclipse.jgit.revwalk.RevWalk.parseCommit(RevWalk.java:800)
at org.sonarsource.scm.git.GitScmProvider.prepareTreeParser(GitScmProvider.java:196)
at org.sonarsource.scm.git.GitScmProvider.branchChangedFiles(GitScmProvider.java:90)
at org.sonar.scanner.scm.ScmChangedFilesProvider.loadChangedFilesIfNeeded(ScmChangedFilesProvider.java:70)
at org.sonar.scanner.scm.ScmChangedFilesProvider.provide(ScmChangedFilesProvider.java:50)
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:63)

Versions are Sonarqube Developer 7.6
Used scanner sonar-maven-plugin with both versions 3.4.0.905 & 3.6.0.1398

Of note is if I attempt to run this locally I get a different error, stack trace is the same until the last few stages as it’s still an issue in GitScmProvider. I’ll post that stack trace in a follow up post.

Also if another member of my team runs this locally, it passes for him, so I suspect it’s not inherently a sonarqube server setup/configuration issue.

Continuing from above, the stack trace from the error when run on my local machine is:

Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scm.ScmChangedFiles
    at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent (ComponentContainer.java:65)
    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:63)

Caused by: java.lang.IllegalArgumentException: Invalid value: diff.algorithm=patience
    at org.eclipse.jgit.lib.DefaultTypedConfigGetter.getEnum (DefaultTypedConfigGetter.java:138)
    at org.eclipse.jgit.lib.Config.getEnum (Config.java:373)
    at org.eclipse.jgit.diff.DiffFormatter.setReader (DiffFormatter.java:212)
    at org.eclipse.jgit.diff.DiffFormatter.setRepository (DiffFormatter.java:180)
    at org.eclipse.jgit.api.DiffCommand.call (DiffCommand.java:124)
    at org.sonarsource.scm.git.GitScmProvider.branchChangedFiles (GitScmProvider.java:92)
    at org.sonar.scanner.scm.ScmChangedFilesProvider.loadChangedFilesIfNeeded (ScmChangedFilesProvider.java:70)
    at org.sonar.scanner.scm.ScmChangedFilesProvider.provide (ScmChangedFilesProvider.java:50)
    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:63)

Locally it’s also been run with sonar-maven-plugin 3.4.0.905 & 3.6.0.1398 as well as earlier versions I can’t remember right now.
Both the machine running the the build in the cloud and my local machine have java 1.8

I’ve used both maven 3.6 & 3.3.9 locally

I also created a new project to run this against with no dependencies and only the sonar-maven-plugin and the error still occurs locally, not tested in azure pipeline.

We also have a separate project that uses gradle which has no problems when running a branch analysis.

@Gareth I’m not convinced your error is the same (hard to tell without @gregpakes full stacktrace).

Anyway I created a ticket:
https://jira.sonarsource.com/browse/SONARSCGIT-38

As a workaround you should remove the diff.algorithm=patience from the .gitconfig of the host running the analysis.

Thanks for the swift reply Julien, it’s greatly appreciated.

Removing the diff.algorithm=patience did fix the problem on my local machine.

However, the other issue with regards to it failing when running in an Azure Devops Pipeline (see my first post on this topic, rather than my follow-up) which does seem to match the original error on this topic is still present. If you’d rather not have them associated I’m happy to move that one to it’s own topic.

Thank you again.

Further update, the empty project passes build analysis fine in azure. I’m wondering if it’s possible that there could be some mismatch in versions for a transitive dependency.

Would be great to open a separate thread for:

Righto, will do as soon as I’ve checked a couple of other things I’ve thought of.

Hi Julien,

We have been facing the same issue lately on azure DevOps pipeline. This is happening only for a few projects.

Can you share me a link to send you logs.

Appreciate your help here.

Thank You.

Hi @shravanipandarmish-g, you can send them to julien.henry@sonarsource.com

Having the same issue. Everything works for the master branch, other than that the coda analysis step fails right after:
SCM collecting changed files in the branch

Any help is greatly appreciated.

Hello Susana

Did you make sure, that you make a full checkout of the code before running branch analysis. E.g. if you use git none of this parameter --depth, --shallow-since, --shallow-exclude, --shallow-submodules should be used when checking out the code.

Best regards
Michal

Hi Michal,

Thanks for following up on this.

Yes, I had made full check outs.
In the meantime, I found out that I needed to create the project in SonarCloud first, and specify in Administration->Branches&Pull Requests which branches to work with prior to running the pipeline in Azure. Otherwise only the master branch gets analysed and its results published. Kudos to my colleague YL.

This is solved, for me at least. :slight_smile:

Hello @budzow. We are running into same issue. However, we cannot do an entire clone. We have to stick to a shallow clone. Is there any workaround in our case?