Error during MSBuild analysis

Hi Ann,

Same error here as well.
Developer Edition Version 9.9.1

The begin command for msbuild works fine but the end command throws the following error:

2024-04-25 10:07:54,035	[INFO]	SonarScanner for MSBuild 5.12
2024-04-25 10:07:54,036	[INFO]	Using the .NET Core version of the Scanner for MSBuild
2024-04-25 10:07:54,099	[INFO]	Post-processing started.
2024-04-25 10:07:54,338	[INFO]	Calling the SonarScanner CLI...
2024-04-25 10:07:54,635	[INFO]	INFO: Scanner configuration file: /opt/1/sonar-scanner-4.8.0.2856/conf/sonar-scanner.properties
2024-04-25 10:07:54,638	[INFO]	INFO: Project root configuration file: /opt/1/product/.sonarqube/out/sonar-project.properties
2024-04-25 10:07:54,718	[INFO]	INFO: SonarScanner 4.8.0.2856
2024-04-25 10:07:54,718	[INFO]	INFO: Java 11.0.22 Ubuntu (64-bit)
2024-04-25 10:07:54,718	[INFO]	INFO: Linux 5.15.0-91-generic amd64
2024-04-25 10:07:55,059	[INFO]	INFO: User cache: ?/.sonar/cache
2024-04-25 10:07:56,058	[INFO]	INFO: Analyzing on SonarQube server 9.9.1.69595
2024-04-25 10:07:56,058	[INFO]	INFO: Default locale: "en_US", source code encoding: "US-ASCII" (analysis is platform dependent)
2024-04-25 10:07:56,568	[INFO]	INFO: Load global settings
2024-04-25 10:07:56,690	[INFO]	INFO: Load global settings (done) | time=122ms
2024-04-25 10:07:56,691	[INFO]	INFO: Server id: 1234567890
2024-04-25 10:07:56,713	[INFO]	INFO: User cache: /opt/1/product/?/.sonar/cache
2024-04-25 10:07:56,714	[INFO]	INFO: Load/download plugins
2024-04-25 10:07:56,715	[INFO]	INFO: Load plugins index
2024-04-25 10:07:56,756	[INFO]	INFO: Load plugins index (done) | time=40ms
2024-04-25 10:07:59,167	[INFO]	INFO: Load/download plugins (done) | time=2453ms
2024-04-25 10:07:59,305	[INFO]	INFO: Loaded core extensions: developer-scanner
2024-04-25 10:07:59,640	[INFO]	INFO: Process project properties
2024-04-25 10:07:59,668	[INFO]	INFO: Process project properties (done) | time=29ms
2024-04-25 10:07:59,671	[INFO]	INFO: Execute project builders
2024-04-25 10:07:59,758	[INFO]	INFO: Execute project builders (done) | time=87ms
2024-04-25 10:07:59,761	[INFO]	INFO: Project key: Key123
2024-04-25 10:07:59,761	[INFO]	INFO: Base dir: /opt/1/product/components
2024-04-25 10:07:59,761	[INFO]	INFO: Working dir: /opt/1/product/.sonarqube/out/.sonar
2024-04-25 10:07:59,768	[INFO]	INFO: Load project settings for component key: 'Key123'
2024-04-25 10:07:59,781	[INFO]	INFO: Load project settings for component key: 'Key123' (done) | time=14ms
2024-04-25 10:07:59,859	[INFO]	INFO: Load project branches
2024-04-25 10:07:59,872	[INFO]	INFO: Load project branches (done) | time=14ms
2024-04-25 10:07:59,873	[INFO]	INFO: Load branch configuration
2024-04-25 10:07:59,877	[INFO]	INFO: Load branch configuration (done) | time=4ms
2024-04-25 10:07:59,935	[INFO]	WARN: SCM provider autodetection failed. Please use "sonar.scm.provider" to define SCM of your project, or disable the SCM Sensor in the project settings.
2024-04-25 10:07:59,943	[INFO]	INFO: Load quality profiles
2024-04-25 10:07:59,986	[INFO]	INFO: Load quality profiles (done) | time=42ms
2024-04-25 10:07:59,990	[INFO]	INFO: Load active rules
2024-04-25 10:08:01,249	[INFO]	INFO: Load active rules (done) | time=1258ms
2024-04-25 10:08:01,254	[INFO]	INFO: Load analysis cache
2024-04-25 10:08:01,268	[INFO]	INFO: Load analysis cache | time=13ms
2024-04-25 10:08:01,313	[INFO]	INFO: Load project repositories
2024-04-25 10:08:01,332	[INFO]	INFO: Load project repositories (done) | time=19ms
2024-04-25 10:08:01,364	[INFO]	INFO: Indexing files...
2024-04-25 10:08:01,365	[INFO]	INFO: Project configuration:
2024-04-25 10:08:01,366	[INFO]	INFO:   Excluded sources for duplication: **/Startup.cs, **/Program.cs
2024-04-25 10:08:01,369	[INFO]	INFO: Indexing files of module 'Hello1'
2024-04-25 10:08:01,370	[INFO]	INFO:   Base dir: /opt/1/product/components/Hello1
2024-04-25 10:08:01,371	[INFO]	INFO:   Excluded sources for duplication: **/Startup.cs, **/Program.cs
2024-04-25 10:08:01,773	[INFO]	INFO: 386 files indexed
2024-04-25 10:08:01,774	[INFO]	INFO: Quality profile for cs: Sonar way
2024-04-25 10:08:01,774	[INFO]	INFO: Quality profile for json: Sonar way
2024-04-25 10:08:01,774	[INFO]	INFO: ------------- Run sensors on module ES
2024-04-25 10:08:01,875	[INFO]	INFO: Load metrics repository
2024-04-25 10:08:01,892	[INFO]	INFO: Load metrics repository (done) | time=17ms
2024-04-25 10:08:02,788	[INFO]	INFO: ------------------------------------------------------------------------
2024-04-25 10:08:02,789	[INFO]	INFO: EXECUTION FAILURE
2024-04-25 10:08:02,789	[INFO]	INFO: ------------------------------------------------------------------------
2024-04-25 10:08:02,789	[INFO]	INFO: Total time: 8.159s
2024-04-25 10:08:02,838	[INFO]	INFO: Final Memory: 21M/84M
2024-04-25 10:08:02,839	[INFO]	INFO: ------------------------------------------------------------------------
2024-04-25 10:08:02,839	[INFO]	ERROR: Error during SonarScanner execution
2024-04-25 10:08:02,839	[INFO]	java.lang.IllegalStateException: Unable to load components interface org.sonar.api.batch.sensor.Sensor
2024-04-25 10:08:02,839	[INFO]    at org.sonar.core.platform.SpringComponentContainer.getComponentsByType(SpringComponentContainer.java:156)
2024-04-25 10:08:02,840	[INFO]    at org.sonar.scanner.bootstrap.AbstractExtensionDictionary.completeScannerExtensions(AbstractExtensionDictionary.java:82)
2024-04-25 10:08:02,840	[INFO]    at org.sonar.scanner.bootstrap.AbstractExtensionDictionary.getExtensions(AbstractExtensionDictionary.java:77)
2024-04-25 10:08:02,840	[INFO]    at org.sonar.scanner.bootstrap.AbstractExtensionDictionary.getFilteredExtensions(AbstractExtensionDictionary.java:67)
2024-04-25 10:08:02,840	[INFO]    at org.sonar.scanner.sensor.ModuleSensorExtensionDictionary.selectSensors(ModuleSensorExtensionDictionary.java:47)
2024-04-25 10:08:02,841	[INFO]    at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$0(ModuleSensorsExecutor.java:54)
2024-04-25 10:08:02,841	[INFO]    at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:79)
2024-04-25 10:08:02,841	[INFO]    at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:54)
2024-04-25 10:08:02,841	[INFO]    at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(SpringModuleScanContainer.java:82)
2024-04-25 10:08:02,842	[INFO]    at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
2024-04-25 10:08:02,842	[INFO]    at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
2024-04-25 10:08:02,842	[INFO]    at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:403)
2024-04-25 10:08:02,842	[INFO]    at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:399)
2024-04-25 10:08:02,842	[INFO]    at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:396)
2024-04-25 10:08:02,843	[INFO]    at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:368)
2024-04-25 10:08:02,843	[INFO]    at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
2024-04-25 10:08:02,843	[INFO]    at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
2024-04-25 10:08:02,843	[INFO]    at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:137)
2024-04-25 10:08:02,843	[INFO]    at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
2024-04-25 10:08:02,844	[INFO]    at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
2024-04-25 10:08:02,844	[INFO]    at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
2024-04-25 10:08:02,844	[INFO]    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
2024-04-25 10:08:02,844	[INFO]    at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
2024-04-25 10:08:02,845	[INFO]    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2024-04-25 10:08:02,845	[INFO]    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2024-04-25 10:08:02,845	[INFO]    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2024-04-25 10:08:02,845	[INFO]    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
2024-04-25 10:08:02,845	[INFO]    at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
2024-04-25 10:08:02,846	[INFO]    at com.sun.proxy.$Proxy0.execute(Unknown Source)
2024-04-25 10:08:02,846	[INFO]    at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
2024-04-25 10:08:02,846	[INFO]    at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
2024-04-25 10:08:02,846	[INFO]    at org.sonarsource.scanner.cli.Main.execute(Main.java:126)
2024-04-25 10:08:02,846	[INFO]    at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
2024-04-25 10:08:02,847	[INFO]    at org.sonarsource.scanner.cli.Main.main(Main.java:62)
2024-04-25 10:08:02,847	[INFO]	Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ClassRealm{python}-org.sonar.plugins.python.PythonSensor': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.sonar.plugins.python.PythonSensor]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/sonarsource/dbd/ir/Instruction
2024-04-25 10:08:02,847	[INFO]    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:315)
2024-04-25 10:08:02,847	[INFO]    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:296)
2024-04-25 10:08:02,848	[INFO]    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372)
2024-04-25 10:08:02,848	[INFO]    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1228)
2024-04-25 10:08:02,848	[INFO]    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
2024-04-25 10:08:02,848	[INFO]    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
2024-04-25 10:08:02,849	[INFO]    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
2024-04-25 10:08:02,849	[INFO]    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
2024-04-25 10:08:02,849	[INFO]    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
2024-04-25 10:08:02,849	[INFO]    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
2024-04-25 10:08:02,850	[INFO]    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:673)
2024-04-25 10:08:02,850	[INFO]    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:661)
2024-04-25 10:08:02,850	[INFO]    at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1302)
2024-04-25 10:08:02,850	[INFO]    at org.sonar.core.platform.SpringComponentContainer.getComponentsByType(SpringComponentContainer.java:154)
2024-04-25 10:08:02,850	[INFO]	... 33 more
2024-04-25 10:08:02,851	[INFO]	Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.sonar.plugins.python.PythonSensor]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/sonarsource/dbd/ir/Instruction
2024-04-25 10:08:02,851	[INFO]    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:224)
2024-04-25 10:08:02,851	[INFO]    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:117)
2024-04-25 10:08:02,851	[INFO]    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:311)
2024-04-25 10:08:02,851	[INFO]	... 46 more
2024-04-25 10:08:02,852	[INFO]	Caused by: java.lang.NoClassDefFoundError: com/sonarsource/dbd/ir/Instruction
2024-04-25 10:08:02,852	[INFO]    at com.sonarsource.dbd.frontend.python.rules.A.<init>(na:812)
2024-04-25 10:08:02,852	[INFO]    at com.sonarsource.dbd.frontend.python.rules.GratuitousBooleanCheck.<init>(na:1342)
2024-04-25 10:08:02,852	[INFO]    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
2024-04-25 10:08:02,853	[INFO]    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
2024-04-25 10:08:02,853	[INFO]    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
2024-04-25 10:08:02,853	[INFO]    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
2024-04-25 10:08:02,853	[INFO]    at java.base/java.lang.Class.newInstance(Class.java:584)
2024-04-25 10:08:02,853	[INFO]    at org.sonar.api.batch.rule.Checks.instantiate(Checks.java:152)
2024-04-25 10:08:02,854	[INFO]    at org.sonar.api.batch.rule.Checks.addAnnotatedChecks(Checks.java:128)
2024-04-25 10:08:02,854	[INFO]    at org.sonar.plugins.python.PythonChecks.addChecks(PythonChecks.java:41)
2024-04-25 10:08:02,854	[INFO]    at org.sonar.plugins.python.PythonChecks.addCustomChecks(PythonChecks.java:49)
2024-04-25 10:08:02,854	[INFO]    at org.sonar.plugins.python.PythonSensor.<init>(PythonSensor.java:90)
2024-04-25 10:08:02,855	[INFO]    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
2024-04-25 10:08:02,855	[INFO]    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
2024-04-25 10:08:02,855	[INFO]    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
2024-04-25 10:08:02,855	[INFO]    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
2024-04-25 10:08:02,855	[INFO]    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:211)
2024-04-25 10:08:02,856	[INFO]	... 48 more
2024-04-25 10:08:02,856	[INFO]	Caused by: java.lang.ClassNotFoundException: com.sonarsource.dbd.ir.Instruction
2024-04-25 10:08:02,856	[INFO]    at org.sonar.classloader.ParentFirstStrategy.loadClass(ParentFirstStrategy.java:39)
2024-04-25 10:08:02,856	[INFO]    at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:87)
2024-04-25 10:08:02,857	[INFO]    at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:76)
2024-04-25 10:08:02,857	[INFO]	... 65 more
2024-04-25 10:08:02,857	[INFO]	ERROR:
2024-04-25 10:08:03,183	[INFO]	The SonarScanner did not complete successfully
2024-04-25 10:08:03,183	[INFO]	09:08:03.183  Post-processing failed. Exit code: 1
2024-04-25 10:08:03,261	[ERROR]	Container Error: Exit Code 1

Many thanks

Hi,

Could you upgrade your scanner to the latest version, 6.2, and see if this is still replicable?

 
Thx,
Ann

Hi Ann,

Upgraded to 6.2 yet same issue unfortunately

Hi,

Can you provide a full, debug job log?

Share the Scanner for .NET verbose logs

  • Add /d:"sonar.verbose=true" to the‚Ķ
    • SonarScanner.MSBuild.exe or dotnet sonarscanner begin command to get more detailed logs
      • For example: SonarScanner.MSBuild.exe begin /k:"MyProject" /d:"sonar.verbose=true"
    • ‚ÄúSonarQubePrepare‚ÄĚ or ‚ÄúSonarCloudPrepare‚ÄĚ task‚Äôs extraProperties argument if you are using Azure DevOps
      • For example:
        - task: SonarCloudPrepare@1
            inputs:
              SonarCloud: 'sonarcloud'
              organization: 'foo'
              scannerMode: 'MSBuild'
              projectKey: 'foo_sonar-scanning-someconsoleapp'
              projectName: 'sonar-scanning-someconsoleapp'
              extraProperties: |
                sonar.verbose=true
        
  • The important logs are in the END step (i.e. SonarQubeAnalyze / SonarCloudAnalyze / ‚ÄúRun Code Analysis‚ÄĚ)

Share the msbuild detailed logs

MsBuild.exe /t:Rebuild /v:d

or

dotnet build -v:d

 
Thx,
Ann

Hi Ann,

The issue turned out to be Jenkins sided and nothing to do with SonarQube. There was a mismatch between the files being indexed so all I had to do was cleaning out the workspace before running the build job. Thanks for all the help Ann!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.