Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoClassDefFoundError after Sonar update from 10.4 to 10.5 #1014

Open
SmallLars opened this issue May 2, 2024 · 20 comments
Open

NoClassDefFoundError after Sonar update from 10.4 to 10.5 #1014

SmallLars opened this issue May 2, 2024 · 20 comments

Comments

@SmallLars
Copy link

Issue Description

Since we updated our Sonar to 10.5 our call to ./gradlew sonar fails.
We can solve the problem by using -Dsonar.plugins.downloadOnlyRequired=false.
Its a Kotlin only project and maybe the detection of the required plugins is broken.

Environment

Component Version
SonarQube 10.5
Sonar-FindBugs 4.2.9
Java 17
Gradle 8.2
Kotlin 1.8.20

Log

> Task :sonar FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':sonar'.
> Error creating bean with name 'ClassRealm{findbugs}-org.sonar.plugins.findbugs.FindbugsConfiguration': Resolution of declared constructors on bean Class [org.sonar.plugins.findbugs.FindbugsConfiguration] from ClassLoader [ClassRealm{findbugs}] failed; nested exception is java.lang.NoClassDefFoundError: org/sonar/plugins/java/api/JavaResourceLocator

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org/.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':sonar'.
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:149)
	at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:147)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:135)
	at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
	at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51)
	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:74)
	at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
	at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:42)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:337)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:324)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:317)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:303)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:463)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:380)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:47)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ClassRealm{findbugs}-org.sonar.plugins.findbugs.FindbugsConfiguration': Resolution of declared constructors on bean Class [org.sonar.plugins.findbugs.FindbugsConfiguration] from ClassLoader [ClassRealm{findbugs}] failed; nested exception is java.lang.NoClassDefFoundError: org/sonar/plugins/java/api/JavaResourceLocator
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:318)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1302)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1219)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:929)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:591)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:225)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:205)
	at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:204)
	at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:200)
	at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:197)
	at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:173)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:226)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:205)
	at org.sonar.scanner.bootstrap.SpringScannerContainer.doAfterStart(SpringScannerContainer.java:351)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:226)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:205)
	at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:138)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:226)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:205)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:71)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:65)
	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(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at jdk.proxy12/jdk.proxy12.$Proxy191.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.sonarqube.gradle.SonarTask.run(SonarTask.java:131)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:125)
	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:58)
	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:51)
	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:29)
	at org.gradle.api.internal.tasks.execution.TaskExecution$3.run(TaskExecution.java:248)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68)
	at org.gradle.api.internal.tasks.execution.TaskExecution.executeAction(TaskExecution.java:233)
	at org.gradle.api.internal.tasks.execution.TaskExecution.executeActions(TaskExecution.java:216)
	at org.gradle.api.internal.tasks.execution.TaskExecution.executeWithPreviousOutputFiles(TaskExecution.java:199)
	at org.gradle.api.internal.tasks.execution.TaskExecution.execute(TaskExecution.java:166)
	at org.gradle.internal.execution.steps.ExecuteStep.executeInternal(ExecuteStep.java:105)
	at org.gradle.internal.execution.steps.ExecuteStep.access$000(ExecuteStep.java:44)
	at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:59)
	at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:56)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
	at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:56)
	at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:44)
	at org.gradle.internal.execution.steps.RemovePreviousOutputsStep.execute(RemovePreviousOutputsStep.java:67)
	at org.gradle.internal.execution.steps.RemovePreviousOutputsStep.execute(RemovePreviousOutputsStep.java:37)
	at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:41)
	at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:74)
	at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:55)
	at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:50)
	at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:28)
	at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.executeDelegateBroadcastingChanges(CaptureStateAfterExecutionStep.java:100)
	at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.execute(CaptureStateAfterExecutionStep.java:72)
	at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.execute(CaptureStateAfterExecutionStep.java:50)
	at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:40)
	at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:29)
	at org.gradle.internal.execution.steps.BuildCacheStep.executeWithoutCache(BuildCacheStep.java:179)
	at org.gradle.internal.execution.steps.BuildCacheStep.lambda$execute$1(BuildCacheStep.java:70)
	at org.gradle.internal.Either$Right.fold(Either.java:175)
	at org.gradle.internal.execution.caching.CachingState.fold(CachingState.java:59)
	at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:68)
	at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:46)
	at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:36)
	at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:25)
	at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:36)
	at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:22)
	at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:91)
	at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$2(SkipUpToDateStep.java:55)
	at java.base/java.util.Optional.orElseGet(Optional.java:364)
	at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:55)
	at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:37)
	at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:65)
	at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:36)
	at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:37)
	at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:27)
	at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:77)
	at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:38)
	at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:94)
	at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:49)
	at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:71)
	at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:45)
	at org.gradle.internal.execution.steps.SkipEmptyWorkStep.executeWithNonEmptySources(SkipEmptyWorkStep.java:177)
	at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:81)
	at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:53)
	at org.gradle.internal.execution.steps.RemoveUntrackedExecutionStateStep.execute(RemoveUntrackedExecutionStateStep.java:32)
	at org.gradle.internal.execution.steps.RemoveUntrackedExecutionStateStep.execute(RemoveUntrackedExecutionStateStep.java:21)
	at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:38)
	at org.gradle.internal.execution.steps.LoadPreviousExecutionStateStep.execute(LoadPreviousExecutionStateStep.java:36)
	at org.gradle.internal.execution.steps.LoadPreviousExecutionStateStep.execute(LoadPreviousExecutionStateStep.java:23)
	at org.gradle.internal.execution.steps.CleanupStaleOutputsStep.execute(CleanupStaleOutputsStep.java:75)
	at org.gradle.internal.execution.steps.CleanupStaleOutputsStep.execute(CleanupStaleOutputsStep.java:41)
	at org.gradle.internal.execution.steps.AssignWorkspaceStep.lambda$execute$0(AssignWorkspaceStep.java:32)
	at org.gradle.api.internal.tasks.execution.TaskExecution$4.withWorkspace(TaskExecution.java:293)
	at org.gradle.internal.execution.steps.AssignWorkspaceStep.execute(AssignWorkspaceStep.java:30)
	at org.gradle.internal.execution.steps.AssignWorkspaceStep.execute(AssignWorkspaceStep.java:21)
	at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:37)
	at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:27)
	at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:47)
	at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:34)
	at org.gradle.internal.execution.impl.DefaultExecutionEngine$1.execute(DefaultExecutionEngine.java:64)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:146)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:135)
	at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
	at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51)
	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:74)
	at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
	at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:42)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:337)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:324)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:317)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:303)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:463)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:380)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:47)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.NoClassDefFoundError: org/sonar/plugins/java/api/JavaResourceLocator
	at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3373)
	at java.base/java.lang.Class.getDeclaredConstructors(Class.java:2555)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:313)
	... 159 more
Caused by: java.lang.ClassNotFoundException: org.sonar.plugins.java.api.JavaResourceLocator
	at org.sonar.classloader.ParentFirstStrategy.loadClass(ParentFirstStrategy.java:39)
	at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:97)
	at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:86)
	... 163 more
@gtoison
Copy link
Contributor

gtoison commented May 2, 2024

Since we updated our Sonar to 10.5 our call to ./gradlew sonar fails. We can solve the problem by using -Dsonar.plugins.downloadOnlyRequired=false. Its a Kotlin only project and maybe the detection of the required plugins is broken.

Thanks for reporting the issue, and I think you've figured out the root of the problem, as well as a workaround.

I've asked the SonarQube team if there's a way to declare a dependency on the built-in sonar-java plugin.

#1015 reproduces the problem

@gtoison
Copy link
Contributor

gtoison commented Jun 6, 2024

For anyone else affected by the issue, it seems that the sonar.plugins.downloadOnlyRequired needs to be set on the server administration page and as an analyzer option.

@gtoison gtoison pinned this issue Jun 22, 2024
@michael-mader
Copy link

For our Maven-based build, setting this option as an analyzer configuration via Maven was sufficient, and the server setting can remain enabled.

@Munken
Copy link

Munken commented Jul 29, 2024

Just to be 100% @gtoison . The solution right now is to set sonar.plugins.downloadOnlyRequired=false?
That seems more like a workaround though, since sonarqube will then continue to download all plugins.

@gtoison
Copy link
Contributor

gtoison commented Jul 29, 2024

Since SonarQube 10.5 the analyzer only downloads the plugins relevant to the languages detected in your project, unless is sonar.plugins.downloadOnlyRequired is set to false.
For non java projects (e.g. kotlin) this causes the Findbugs plugin to crash, because it needs the built in sonar-java plugin.

It is a workaround, but last time I have checked Sonarsource said that they do not intend to provide plugins with a way to express dependencies on another plugin.

@michael-mader
Copy link

so the correct fix requires the sonar-java plugin to add the kt file suffix?

@gtoison
Copy link
Contributor

gtoison commented Jul 31, 2024

so the correct fix requires the sonar-java plugin to add the kt file suffix?

I doubt Sonarsource would change that in their built-in plugin: it is for java, not Kotlin. We happen to be using it here because it locates the compiled .class files.

One way would be for Sonarsource to let plugin express a plugin dependency: the Findbugs plugin could then say that it always needs the sonar-java plugin. They have considered it but most probably won't do it.

Another way would be for the Findbugs plugin to no longer depend on the sonar-java plugin. That would entail rewriting some of the code from sonar-java, and maintaining it. Finding the time to do that is a bit challenging for me right now but contributions are much welcome!

@Munken
Copy link

Munken commented Jul 31, 2024

We are seeing this problem in Java projects, which are using Kotlin for the gradle file.

@gtoison
Copy link
Contributor

gtoison commented Jul 31, 2024

Hum, Sonarqube should activate the sonar-java plugin if it sees .java sources (unless they are filtered out?)
Is that a multi-module project with some .java sources only in some modules?

@Munken
Copy link

Munken commented Jul 31, 2024

I tried this with a Java project with Kotlin gradle file:

> Task :sonar FAILED
0 files ignored because of scm ignore settings
Loading plugins for detected languages
Load/download plugins
Load/download plugins (done) | time=33ms
Load project repositories
Load project repositories (done) | time=82ms
Indexing files...
Project configuration:
Quality profile for java: Sonar way
Quality profile for kotlin: Sonar way
------------- Run sensors on module mmu-lib-tester

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':sonar'.
> Error creating bean with name 'ClassRealm{findbugs}-org.sonar.plugins.findbugs.FindbugsConfiguration': Resolution of declared constructors on bean Class [org.sonar.plugins.findbugs.FindbugsConfiguration] from ClassLoader [ClassRealm{findbugs}] failed; nested exception is java.lang.NoClassDefFoundError: org/sonar/plugins/java/api/JavaResourceLocator

Replacing the kotlin gradle file with a groovy gradle file yields a similar result:

Quality profile for java: Sonar way
------------- Run sensors on module mmu-lib-tester

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':sonar'.
> Error creating bean with name 'ClassRealm{findbugs}-org.sonar.plugins.findbugs.FindbugsConfiguration': Resolution of declared constructors on bean Class [org.sonar.plugins.findbugs.FindbugsConfiguration] from ClassLoader [ClassRealm{findbugs}] failed; nested exception is java.lang.NoClassDefFoundError: org/sonar/plugins/java/api/JavaResourceLocator

@Munken
Copy link

Munken commented Jul 31, 2024

The pure java write the following in the debug log:

2024-07-31T22:17:20.182+0200 [INFO] [org.sonarqube.gradle.SonarTask] Loading plugins for detected languages
2024-07-31T22:17:20.182+0200 [DEBUG] [org.sonarqube.gradle.SonarTask] Detected languages: [java]
2024-07-31T22:17:20.182+0200 [INFO] [org.sonarqube.gradle.SonarTask] Load/download plugins
2024-07-31T22:17:20.215+0200 [INFO] [org.sonarqube.gradle.SonarTask] Load/download plugins (done) | time=32ms
2024-07-31T22:17:20.215+0200 [DEBUG] [org.sonarqube.gradle.SonarTask] Optional language-specific plugins not loaded: [abap, sonarapex, csharp, cpp, cobol, dbdpythonfrontend, flex, go, web, javascript, kotlin, pli, plsql, rpg, ruby, sonarscala, swift, tsql, vbnet, vb, securitycsharpfrontend, securityjsfrontend, securityphpfrontend, securitypythonfrontend]
2024-07-31T22:17:20.248+0200 [DEBUG] [org.sonarqube.gradle.SonarTask] Plugins loaded:
2024-07-31T22:17:20.248+0200 [DEBUG] [org.sonarqube.gradle.SonarTask]   * Vulnerability Rules for Java 10.4.0.30099 (securityjavafrontend)
2024-07-31T22:17:20.248+0200 [DEBUG] [org.sonarqube.gradle.SonarTask]   * Vulnerability Analysis 10.4.0.30099 (security)
2024-07-31T22:17:20.248+0200 [DEBUG] [org.sonarqube.gradle.SonarTask]   * Java Code Quality and Security 7.30.0.34429 (java)
2024-07-31T22:17:20.248+0200 [DEBUG] [org.sonarqube.gradle.SonarTask]   * Dataflow Bug Detection Rules for Java 1.22.0.7341 (dbdjavafrontend)
2024-07-31T22:17:20.248+0200 [DEBUG] [org.sonarqube.gradle.SonarTask]   * Dataflow Bug Detection 1.22.0.7341 (dbd)

@gtoison
Copy link
Contributor

gtoison commented Aug 1, 2024

There is a multi-module project built and analyzed as part of the integration tests in this project, it seems to work OK with Gradle so I'm not sure what might be different for you @Munken
Could you please have a look at it and see if anything seems different? https://github.com/spotbugs/sonar-findbugs/tree/master/src/test/resources/projects/multi-module

@Munken
Copy link

Munken commented Aug 7, 2024

@gtoison running

./gradlew sonarqube -Dsonar.plugins.downloadOnlyRequired=true

on the multi module project yields the same error.

My point is that this plugin seems to break even on pure java projects.

@gtoison
Copy link
Contributor

gtoison commented Aug 8, 2024

I've made a Pull Request with changes to hopefully solve this problem: in #1033 the plugin does not rely on the built-in sonar-java. So it should work even if Sonarqube decides that the project does not need to download sonar-java.

If anyone affected here could test this with a real-world project that would be much appreciated. Check out the https://github.com/gtoison/sonar-findbugs/tree/bunde-sonar-java branch and run mvn clean package to build the jar.
Note that this change breaks compatibility with SonarQube < 9.9 but it shouldn't be a problem for users affected by this issue.

@Munken
Copy link

Munken commented Aug 14, 2024

Hi @gtoison

I tested with -Dsonar.plugins.downloadOnlyRequired=true with a pure Java project and Java + gradle kotlin project.

  • sonar-findbugs 4.2.6 => NoClassDefFoundError
  • sonar-findbugs 4.3.0-snapshot (e15be92) => all ok

So the changes in #1033 work on our system. Please release ASAP 👍

However, in #1033 .github/workflows/sonarqube.yml / build (pull_request_target) is failing with

The following artifacts could not be resolved: org.sonarsource.api.plugin:sonar-plugin-api:jar:8.9.9.56886 

@Munken
Copy link

Munken commented Aug 15, 2024

Nevermind, that last paragraph.
As you said:

Note that this change breaks compatibility with SonarQube < 9.9 but it shouldn't be a problem for users affected by this issue.

@gtoison
Copy link
Contributor

gtoison commented Aug 26, 2024

Thanks a lot for trying out the fix @Munken
I looked at the change a bit more carefully and realized I had duplicated part of the existing code, I'm making another PR here: #1035

@Munken
Copy link

Munken commented Sep 24, 2024

@gtoison what is blocking this? Something you need help with?

@gtoison
Copy link
Contributor

gtoison commented Sep 30, 2024

Sorry, it's mostly the lack of free time on my end.
I wanted to properly test #1035 and also wanted to upgrade SpotBugs itself as we are wrapping up the release of version 4.9.0

@gtoison
Copy link
Contributor

gtoison commented Oct 31, 2024

This issue should be fixed in version 4.3.0 released yesterday

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants