Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in Sonar while executing Findbug rules

I'm getting following error after configuring my sonar project with findbugs. Please help me out.

BUILD FAILED
17-May-2013 11:18:15    /home/build/bamboo-home/xml-data/build-dir/EZIO-EMA-JOB1/build.xml:247: org.sonar.api.utils.SonarException: Can not execute Findbugs
17-May-2013 11:18:15            at org.sonar.plugins.findbugs.FindbugsExecutor.execute(FindbugsExecutor.java:120)
17-May-2013 11:18:15            at org.sonar.plugins.findbugs.FindbugsSensor.analyse(FindbugsSensor.java:58)
17-May-2013 11:18:15            at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:64)
17-May-2013 11:18:15            at org.sonar.batch.phases.Phases.execute(Phases.java:93)
17-May-2013 11:18:15            at org.sonar.batch.bootstrap.ProjectModule.doStart(ProjectModule.java:143)
17-May-2013 11:18:15            at org.sonar.batch.bootstrap.Module.start(Module.java:89)
17-May-2013 11:18:15            at org.sonar.batch.bootstrap.BatchModule.analyze(BatchModule.java:110)
17-May-2013 11:18:15            at org.sonar.batch.bootstrap.BatchModule.doStart(BatchModule.java:100)
17-May-2013 11:18:15            at org.sonar.batch.bootstrap.Module.start(Module.java:89)
17-May-2013 11:18:15            at org.sonar.batch.bootstrap.BootstrapModule.doStart(BootstrapModule.java:96)
17-May-2013 11:18:15            at org.sonar.batch.bootstrap.Module.start(Module.java:89)
17-May-2013 11:18:15            at org.sonar.batch.Batch.execute(Batch.java:74)
17-May-2013 11:18:15            at org.sonar.ant.Launcher.execute(Launcher.java:70)
17-May-2013 11:18:15            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
17-May-2013 11:18:15            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
17-May-2013 11:18:15            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
17-May-2013 11:18:15            at java.lang.reflect.Method.invoke(Method.java:597)
17-May-2013 11:18:15            at org.sonar.ant.SonarTask.delegateExecution(SonarTask.java:202)
17-May-2013 11:18:15            at org.sonar.ant.SonarTask.execute(SonarTask.java:186)
17-May-2013 11:18:15            at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
17-May-2013 11:18:15            at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
17-May-2013 11:18:15            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
17-May-2013 11:18:15            at java.lang.reflect.Method.invoke(Method.java:597)
17-May-2013 11:18:15            at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
17-May-2013 11:18:15            at org.apache.tools.ant.Task.perform(Task.java:348)
17-May-2013 11:18:15            at org.apache.tools.ant.Target.execute(Target.java:390)
17-May-2013 11:18:15            at org.apache.tools.ant.Target.performTasks(Target.java:411)
17-May-2013 11:18:15            at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1360)
17-May-2013 11:18:15            at org.apache.tools.ant.Project.executeTarget(Project.java:1329)
17-May-2013 11:18:15            at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
17-May-2013 11:18:15            at org.apache.tools.ant.Project.executeTargets(Project.java:1212)
17-May-2013 11:18:15            at org.apache.tools.ant.Main.runBuild(Main.java:801)
17-May-2013 11:18:15            at org.apache.tools.ant.Main.startAnt(Main.java:218)
17-May-2013 11:18:15            at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
17-May-2013 11:18:15            at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
17-May-2013 11:18:15    Caused by: org.sonar.api.utils.SonarException: Findbugs needs sources to be compiled. Please build project before executing sonar and check the location of compiled classes.
17-May-2013 11:18:15            at org.sonar.plugins.findbugs.FindbugsConfiguration.getFindbugsProject(FindbugsConfiguration.java:66)
17-May-2013 11:18:15            at org.sonar.plugins.findbugs.FindbugsExecutor.execute(FindbugsExecutor.java:74)
17-May-2013 11:18:15            ... 34 more
like image 645
Amit Kumar Avatar asked Nov 28 '22 16:11

Amit Kumar


2 Answers

The Exception message is clear about the problem, but not about the solution, which is: at the same place where you defined the sonar.sources property, add a sonar.binaries property that points to the location of the compiled code. For example, in a maven project you would typically have sonar.binaries=target/classes.

like image 131
Paulo Merson Avatar answered Dec 16 '22 18:12

Paulo Merson


Include the below lines in the jenkins job configuration under execute SonarQube Scanner:

sonar.java.binaries=${workspace}/target/classes/

sonar.binaries=${workspace}/target/classes/

like image 45
MeowRude Avatar answered Dec 16 '22 20:12

MeowRude