Problems running sonar with MIlestone-5


(Joel Robotham) #1

I’m currently working through the last few issues in upgrading from Milestone-3 -> Milestone-5 and have run into some problems getting sonar to work. I’ve distilled it down to something quite simple and am still getting an exception.

Basically, I have a build.gradle that looks something like:

apply plugin: 'java'
apply plugin: 'sonar'
  project.sonar.server.url = "http://sonar_url/"

Where sonar_url is a currently running sonar instance that our Milestone-3 gradle build talks to.

When I run “gradle sonarAnalyze”, I get the following stacktrace:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':sonarAnalyze'.
 at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:71)
 at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:48)
 at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:34)
 at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:55)
 at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:57)
 at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:41)
 at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
 at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:52)
 at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:42)
 at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:243)
 at org.gradle.execution.DefaultTaskGraphExecuter.executeTask(DefaultTaskGraphExecuter.java:192)
 at org.gradle.execution.DefaultTaskGraphExecuter.doExecute(DefaultTaskGraphExecuter.java:177)
 at org.gradle.execution.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:83)
 at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:36)
 at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:70)
 at org.gradle.execution.DefaultBuildExecuter.access$300(DefaultBuildExecuter.java:23)
 at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:80)
 at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
 at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:70)
 at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:63)
 at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:157)
 at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:112)
 at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:80)
 at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:42)
 at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:28)
 at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:32)
 at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:21)
 at org.gradle.launcher.cli.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:233)
 at org.gradle.launcher.cli.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:217)
 at org.gradle.launcher.Main.doAction(Main.java:48)
 at org.gradle.launcher.exec.EntryPoint$1.execute(EntryPoint.java:53)
 at org.gradle.launcher.exec.EntryPoint$1.execute(EntryPoint.java:51)
 at org.gradle.launcher.exec.Execution.execute(Execution.java:28)
 at org.gradle.launcher.exec.EntryPoint.run(EntryPoint.java:39)
 at org.gradle.launcher.Main.main(Main.java:39)
 at org.gradle.launcher.ProcessBootstrap.runNoExit(ProcessBootstrap.java:51)
 at org.gradle.launcher.ProcessBootstrap.run(ProcessBootstrap.java:33)
 at org.gradle.launcher.GradleMain.main(GradleMain.java:24)
Caused by: java.lang.NoClassDefFoundError: org/sonar/api/batch/bootstrap/ProjectDefinition
 at org.gradle.api.plugins.sonar.SonarAnalyze.analyze(SonarAnalyze.groovy:46)
 at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:158)
 at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:93)
 at org.gradle.api.plugins.sonar.SonarAnalyze_Decorated.invokeMethod(Unknown Source)
 at org.gradle.util.ReflectionUtil.invoke(ReflectionUtil.groovy:23)
 at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$2.execute(AnnotationProcessingTaskFactory.java:129)
 at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$2.execute(AnnotationProcessingTaskFactory.java:127)
 at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:63)
 ... 37 more
Caused by: java.lang.ClassNotFoundException: org.sonar.api.batch.bootstrap.ProjectDefinition
 at org.sonar.batch.bootstrapper.BootstrapClassLoader.findClass(BootstrapClassLoader.java:52)
 at org.sonar.batch.bootstrapper.BootstrapClassLoader.loadClass(BootstrapClassLoader.java:86)
 ... 45 more

We’re currently using sonar version 2.8.

Any ideas?


(Peter Niederwieser) #2

As stated in the user guide, the new Sonar plugin requires Sonar 2.9 or higher.


(Joel Robotham) #3

Thanks Peter, missed that one. I’ll upgrade sonar when I get a chance.

Would it be worth adding that point to the migration guide?


(Peter Niederwieser) #4

Good idea, I’ve added it.