NoClassDeffFoundError during SonarScanner execution

Hi!

I’m trying to analyse a java project with sonar-scanner. During analysis i get an error that classes which are needed to implement customized rules were not found.

I’m using:

SonarQube Community Edition Version 8.5.1 (build 38104)
INFO: SonarScanner 4.5.0.2216
INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
INFO: Windows 10 10.0 amd64

Error log:

 ERROR: Error during SonarScanner execution
 java.lang.NoClassDefFoundError: org/sonar/java/model/expression/MemberSelectExpressionTreeImpl
         at org.sonar.samples.java.checks.ThreadRule.visitImport(ThreadRule.java:29)
         at org.sonar.java.model.JavaTree$ImportTreeImpl.accept(JavaTree.java:366)
         at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:40)
         at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:34)
         at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitCompilationUnit(BaseTreeVisitor.java:51)
         at org.sonar.java.model.JavaTree$CompilationUnitTreeImpl.accept(JavaTree.java:189)
         at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:40)
         at org.sonar.samples.java.checks.ThreadRule.scanFile(ThreadRule.java:22)
         at org.sonar.java.model.VisitorsBridge.lambda$runScanner$0(VisitorsBridge.java:180)
         at org.sonar.java.model.VisitorsBridge.runScanner(VisitorsBridge.java:185)
         at org.sonar.java.model.VisitorsBridge.runScanner(VisitorsBridge.java:180)
         at org.sonar.java.model.VisitorsBridge.visitFile(VisitorsBridge.java:160)
         at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:98)
         at org.sonar.java.ast.JavaAstScanner.scan(JavaAstScanner.java:64)
         at org.sonar.java.JavaSquid.scanSources(JavaSquid.java:114)
         at org.sonar.java.JavaSquid.scan(JavaSquid.java:107)
         at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:103)
         at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
         at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
         at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
         at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
         at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
         at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
         at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
         at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
         at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:393)
         at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:389)
         at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:358)
         at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
         at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
         at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:144)
         at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
         at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
         at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
         at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
         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:189)
         at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
         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.ClassNotFoundException: org.sonar.java.model.expression.MemberSelectExpressionTreeImpl
         at org.sonar.classloader.ParentFirstStrategy.loadClass(ParentFirstStrategy.java:39)
         at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:87)
         at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:76)
         ... 47 more

Thanks in advance!

Hi,

To be clear, you’ve written custom rules, deployed that plugin to your SonarQube server and are now getting an error during analysis?

 
Ann

Hi Ann!

Yes, that’s right.

Nik

Okay, then this is about debugging your custom rules. I’m going to move this thread to that category.

 
Ann