Error during SonarQube Scanner execution with sonar python enabled - sonarqube

I am a very new sonarqube user, experimenting with my python project.
I have installed docker Sonarqube image which has Sonarpython plugin installed. I installed the linux base sonar scanner.
Using these instructions, I configured the scanner.
However when running it, I run into:
11:28:33.486 INFO: Configured Java source version (sonar.java.source): none
11:28:33.496 INFO: JavaClasspath initialization
11:28:33.512 INFO: ------------------------------------------------------------------------
11:28:33.512 INFO: EXECUTION FAILURE
11:28:33.512 INFO: ------------------------------------------------------------------------
11:28:33.513 INFO: Total time: 22.237s
11:28:33.670 INFO: Final Memory: 28M/509M
11:28:33.671 INFO: ------------------------------------------------------------------------
11:28:33.671 ERROR: Error during SonarQube Scanner execution
org.sonar.java.AnalysisException: Please provide compiled classes of your project with sonar.java.binaries property
at org.sonar.java.JavaClasspath.init(JavaClasspath.java:66)
at org.sonar.java.AbstractJavaClasspath.getElements(AbstractJavaClasspath.java:280)
at org.sonar.java.SonarComponents.getJavaClasspath(SonarComponents.java:175)
at org.sonar.java.JavaSquid.<init>(JavaSquid.java:82)
at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:91)
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:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:359)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:354)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:317)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:128)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:73)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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:185)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:137)
at org.sonarsource.scanner.cli.Main.execute(Main.java:111)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Do I need to configure sonar.java.source to successfully scan?

As soon as you are having some Java sources in your project, SonarQube is going to ask you for the compiled binaries as well in order to perform the analysis. It let you with 2 choices:
If you want to focus on Python code only, then ignore java code by properly excluding it with the following scanner property: sonar.exclusions=**/*.java. For more information regarding exclusions, you can have a look at this page: SonarQube 7.7 - Narrowing the focus. Another way could be to only include python files, which would ignore all the other one. We however recommend to have the broader analysis possible.
If you want to also analyse your Java code, then build your project first, and provide the path to your binaries and libraries (optional) using the following properties: sonar.java.binaries and sonar.java.libraries. Refer to this documentation page for configuration: Java Plugin and Bytecode

Related

Sonarqube scanner error DirectoryNotEmptyException

I am using sonarqube scanner on a Citrix remote machine. During the scan, analysis of code completes and gets zipped. But while uploading this zipped file, I get java.nio.file.DirectoryNotEmptyException and nothing gets uploaded to the sonarqube server.
Note that the scanner works fine for small projects. It does not work only for large projects. My sonarqube version is 7.2.1. Same thing happened in version 6.7 LTS. But it worked perfectly fine in version 5.6 LTS.
I have tried setting sonar.ws.timeout=9000 in sonar-scanner.properties file to increase time. This did not work.
The error message is:
INFO: 7 files had no CPD blocks
INFO: Calculating CPD for 521 files
INFO: CPD calculation finished
INFO: Analysis report generated in 4886ms, dir size=15 MB
INFO: Analysis reports compressed in 3769ms, zip size=4 MB
ERROR: Failed to delete temp folder
java.nio.file.DirectoryNotEmptyException: C:\codeAnalyzer\bhatk\.scannerwork\.sonartmp
at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProv
ider.java:266)
at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSyst
emProvider.java:108)
at java.nio.file.Files.deleteIfExists(Files.java:1165)
at org.sonar.api.utils.internal.DefaultTempFolder$DeleteRecursivelyFileV
isitor.postVisitDirectory(DefaultTempFolder.java:121)
at org.sonar.api.utils.internal.DefaultTempFolder$DeleteRecursivelyFileV
isitor.postVisitDirectory(DefaultTempFolder.java:110)
at java.nio.file.Files.walkFileTree(Files.java:2688)
at java.nio.file.Files.walkFileTree(Files.java:2742)
at org.sonar.api.utils.internal.DefaultTempFolder.clean(DefaultTempFolde
r.java:97)
at org.sonar.api.utils.internal.DefaultTempFolder.stop(DefaultTempFolder
.java:106)
at org.sonar.scanner.analysis.AnalysisTempFolderProvider.stop(AnalysisTe
mpFolderProvider.java:61)
at org.picocontainer.DefaultPicoContainer.stopAdapters(DefaultPicoContai
ner.java:1048)
at org.picocontainer.DefaultPicoContainer.stop(DefaultPicoContainer.java
:803)
at org.sonar.core.platform.ComponentContainer.stopComponents(ComponentCo
ntainer.java:165)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer
.java:124)
at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:
81)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentC
ontainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer
.java:122)
at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContain
er.java:132)
at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:71)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.exec
ute(BatchIsolatedLauncher.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(Iso
latedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner
.java:171)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.j
ava:128)
at org.sonarsource.scanner.cli.Main.execute(Main.java:111)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 3:27.575s
INFO: Final Memory: 60M/2882M
INFO: -----------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: Fail to request http://localhost:9000/api/ce/submit?projectKey=my:project
&projectName=My%20project
ERROR: Caused by: timeout
ERROR: Caused by: Socket closed
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging
.
the error caused by default 10s writeTimeout inherited from OkHttp library. While readTimeout is configurable by sonar.ws.timeout param, the writeTimout is not currently configurable. In some cases, depends on the analysis report size and /or your infrastructure setup, 10s is not enough to upload an analysis report that causes socket timeout error and DirectoryNotEmptyException. I have implemented a fix and committed it to SonarSource github: https://github.com/SonarSource/sonarqube/pull/3252/files

SonarQube upgrade from 6.4 to 6.5 breaks the scanner

I am on sonarQube6.4 and have upgraded to 6.5
Sonar-scanner is 3.0.3
Now after the upgrade the scanner fails anytime there is a java file in the source path. If I don't scan java files everything works just fine.
However If I rollback an use 6.4 version, everything works fine, so is there any regression? This is the stack trace, when I run the scanner command with -X command. So is it a mandate in 6.5 to provided the location of all compiled classed, is there a way to ignore it.
04:56:21.218 DEBUG: Sensors : JavaSquidSensor -> SurefireSensor ->
JaCoCoSensor -> SonarJavaXmlFileSensor -> Analyzer for "php.ini" files
-> Zero Coverage Sensor -> CPD Block Indexer 04:56:21.218 INFO: Sensor JavaSquidSensor [java] 04:56:21.558 INFO: Configured Java source
version (sonar.java.source): none 04:56:21.565 INFO: JavaClasspath
initialization 04:56:21.570 INFO:
------------------------------------------------------------------------ 04:56:21.571 INFO: EXECUTION FAILURE 04:56:21.571 INFO:
------------------------------------------------------------------------ 04:56:21.571 INFO: Total time: 6.545s 04:56:21.707 INFO: Final Memory:
51M/1083M 04:56:21.707 INFO:
------------------------------------------------------------------------ 04:56:21.707 ERROR: Error during SonarQube Scanner execution
org.sonar.squidbridge.api.AnalysisException: Please provide compiled
classes of your project with sonar.java.binaries property
at org.sonar.java.JavaClasspath.init(JavaClasspath.java:59)
at org.sonar.java.AbstractJavaClasspath.getElements(AbstractJavaClasspath.java:281)
at org.sonar.java.SonarComponents.getJavaClasspath(SonarComponents.java:141)
at org.sonar.java.JavaSquid.(JavaSquid.java:83)
at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:83)
at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)
at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:88)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:82)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:68)
at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:78)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:179)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:144)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:129)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:261)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:256)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:245)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:144)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:129)
at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47)
at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:84)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:144)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:129)
at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:119)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:116)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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:233)
at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:123)
at org.sonarsource.scanner.cli.Main.execute(Main.java:77)
at org.sonarsource.scanner.cli.Main.main(Main.java:61) 04:56:21.710 DEBUG: Execution getVersion 04:56:21.711 DEBUG: Execution
stop
When I run the same with 6.4, it works fine and the only warning I see in the console is :
04:52:42.738 WARN: Bytecode of dependencies was not provided for analysis of source files, you might end up with less precise results. Bytecode can be provided using sonar.java.libraries property
Error during SonarQube Scanner execution
org.sonar.squidbridge.api.AnalysisException: Please provide compiled
classes of your project with sonar.java.binaries property
Since SonarJava 4.12, you must specify sonar.java.binaries property https://docs.sonarqube.org/display/PLUG/Java+Plugin+and+Bytecode
Example :
sonar-scanner -Dsonar.projectKey=fr.demo:my-project -Dsonar.sources=. -Dsonar.java.binaries=.
The error message says:
Error during SonarQube Scanner execution org.sonar.squidbridge.api.AnalysisException:
Please provide compiled classes of your project with sonar.java.binaries property
It seems like the java sensor requires the .class files, in addition to the .java files.
You could:
Add those files to the analysis (it will by the way give you more valuable sonar findings!)
Try adding and removing files to find out, which piece of code causes the issue and report it as a Sonar Java bug
I had this issue as well and I fixed it in the following way:
This page mentions about an entry which was optional before and became mandatory during the latest update (4.12). It says that the sonar.java.binaries entry in the Jenkins project settings should be set. When set, even to a faulty folder, it will fix your errors, leaving only a warning and your pipeline will be running again.
The setting should be added to Jenkins -> "your project" -> Configuration -> Build -> Execute SonarQube Scanner -> Analysis Properties. Add this entry and point it to your binaries folder.
Even i was also facing same issue after SonarQube upgrade to latest 6.5 version. But after downgrading SonarJava plugin(from 4.12 to 4.11), it worked.
Hope it will help you.

Unable to run Sonar with Hybris

I am new to SonarQube and trying to run the analytics on all the extensions in one go. I am able to run it successfully for extensions individually but when I run "ant sonar" with hybris, it gives me below exception:
[echo] - sonar.jdbc.url : ${sonar.jdbc.url}
[echo] - sonar.projectName : Superproject
[echo] - sonar.project.key : superprojectkey
[echo] - sonar.project.version : 1.0
[echo] - sonar.excludedExtensions :
[echo] - sonar.language : java
[echo] *************************************************
[echo]
r:sonar] Apache Ant(TM) version 1.9.1 compiled on May 15 2013
r:sonar] Sonar Ant Task version: 2.1
r:sonar] Loaded from: file:/E:/hybris/bin/platform/resources/ant
r:sonar] INFO: Default locale: "en_IN", source code encoding: "UTF-8"
r:sonar] INFO: Work directory: E:\hybris\bin\platform\.sonar
r:sonar] ERROR: Sonar server 'http://localhost:9000' can not be reached
E:\\hybris\bin\platform\resources\ant\sonar.xml:84: org.sonar.runner.kevinsawicki.Ht
at org.sonar.runner.kevinsawicki.HttpRequest.code(HttpRequest.java:1392)
at org.sonar.runner.kevinsawicki.HttpRequest.ok(HttpRequest.java:1417)
at org.sonar.runner.impl.ServerConnection.downloadString(ServerConnection.java:83)
at org.sonar.runner.impl.ServerVersion.downloadVersion(ServerVersion.java:49)
at org.sonar.runner.impl.ServerVersion.version(ServerVersion.java:40)
at org.sonar.runner.impl.ServerVersion.is35Compatible(ServerVersion.java:64)
at org.sonar.runner.impl.JarDownloader.download(JarDownloader.java:39)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:59)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:57)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:71)
at org.sonar.runner.api.Runner.execute(Runner.java:89)
at org.sonar.ant.SonarTask.launchAnalysis(SonarTask.java:53)
at org.sonar.ant.SonarTask.execute(SonarTask.java:48)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:396)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.Main.runBuild(Main.java:851)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Caused by: java.net.ConnectException: Connection refused: connect
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1890)
at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1885)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1884)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1457)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
at org.sonar.runner.kevinsawicki.HttpRequest.code(HttpRequest.java:1390)
... 44 more
I know this is an configuration issue but I could not locate the file where the LOG is saying it is.
Also, why is it requiring jdbc url?
Thanks.
i just write down the approach we are using within our projects - not exactly as we are wrapping ant with gradle but how we proceed and configure everything.
We are not using the ant sonar scanner but either, the gradle sonar scanner [1] or the jenkins sonar scanner [2], so in this case you could actually use the sonar scanner [3].
Configuring sonar properties:
you can easily put all your configurations in your project root in a file called sonar-project.properties.
sonar.host.url=<sonar url>
sonar.projectKey=<project key>
sonar.projectName=<project name>
# you could use here java as language, but if you also want to analyse JS and other languages remove it, and adapt the source path to add those too
sonar.language=java
sonar.sources=<path-to-extension>/src,\
<path-to-extension>/hmc/src,\
<path-to-extension>/web/src,\
sonar.tests=<path-to-extension>/testsrc
sonar.java.binaries=**/classes
sonar.java.libraries=**/*.jar
sonar.java.test.binaries=**/classes
sonar.java.test.libraries=**/*.jar
this is just a simple basic configuration - so you need to define your test plugin and paths in here too.
i added paths for web and hmc, if your extension is not using them remove them
i just added one extensions, you could simply extend it with multiple ones
every config you do, you can simply put into this sonar-project.properties, and you can even check it into your VCS, to share it with others.
benefits are that this settings are connected with your source, so if you have a new extension you also adapt the sonar settings, and do not need to adapt any build etc.
Running the scanner
now you can simple use every runner you like by using those project properties. either jenkins, or gradle or local, you just need to ensure that the sonar-project.properties file is in the root of your project, and pointing to the right files.
Acknowledge
i know this is not the default hybris way, and it is not using the ant target of hybris, but i figured out, that this approach gives me much more flexibility than the default way!
[1] https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Gradle?src=contextnavpagetreemode
[2] https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Jenkins
[3] https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner
are you sure that the Sonarqube server is launched? Maybe launch it manually and be sure that is is visible in your browser when accessing locallhost:9000/about .
As the root problem is the sonarserver not being available i'd go for that...
The Sonar Host URL is configured through a property called sonar.host.url
On the project I was working a while ago this property was set in hybris\config\local.properties
Related to the INFO: Work directory: E:\hybris\bin\platform.sonar logged,
I think that the working directory can be set using the sonar.working.directory which ,if not set, is somehow computed to be the one you saw in logs (i.e hybris\bin\platform.sonar)

SonarQube Nullpointer on analysis, missing fields or rules parameters

I'm running into a nullpointer exception when running analysis on a java project.
The condition that triggers the analysis failure only happens when I activate certain Rules in the Quality Profile. Particularly, any rule that has a parameter you can override, causes the nullpointer failure. It fails whether or not I provide an override value or if the parameter is left default.
I should note that I can get successful analysis to complete if those particular rules are deactivated in the quality profile. It only seems to be related to certain rules that have parameters.
I can replicate this Nullpointer failure with both the sonar-runner, and the org.sonarqube gradle plugin (v 1.0). So I suspect it is not a problem with the runner or the plugin but some kind of setup issue with the SonarQube server and/or database.
The problem is, I don't know how to go in and fix this issue. The SonarQube database isn't documented (that I'm aware) I suspect that there is something maybe missing in the database but I'm not even sure where they might be.
Any suggestions on where I might look?
Versions:
SonarQube 4.5.2
SonarQube Runner 2.4
Java 1.8.0_40 Oracle Corporation (64-bit)
Mac OS X 10.10.4 x86_64
Here is the stack trace of the error:
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 1:43.316s
Final Memory: 27M/635M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at org.sonar.runner.Main.executeTask(Main.java:70)
at org.sonar.runner.Main.execute(Main.java:59)
at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.NullPointerException
at org.sonar.api.batch.rule.Checks.getField(Checks.java:180)
at org.sonar.api.batch.rule.Checks.configureFields(Checks.java:167)
at org.sonar.api.batch.rule.Checks.instantiate(Checks.java:152)
at org.sonar.api.batch.rule.Checks.addAnnotatedChecks(Checks.java:127)
at org.sonar.java.SonarComponents.registerTestCheckClasses(SonarComponents.java:128)
at org.sonar.plugins.java.JavaSquidSensor.analyse(JavaSquidSensor.java:82)
at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:79)
at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:70)
at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:119)
at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:194)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:233)
at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:228)
at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:221)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:64)
at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:51)
at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:125)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
at org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapContainer.java:173)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
... 9 more
We solved the problem, and the problem was indeed the Java plugin on the SonarQube server. The solution was to downgrade the Java plugin though. Here are the versions we ended up using:
Checkstyle [checkstyle] 2.2 Analyze Java code with Checkstyle.
Clover [clover] 3.0 Get code coverage with Atlassian Clover.
Cobertura [cobertura] 1.6.3 Get code coverage with Cobertura.
Findbugs [findbugs] 3.1 Analyze Java code with Findbugs 3.0.0.
Java [java] 2.9.1 SonarQube rule engine.
JIRA [jira] 1.2 Connects SonarQube to Atlassian JIRA in various ways.
LDAP [ldap] 1.4 Delegates authentication to LDAP.
PMD [pmd] 2.3 Analyze Java code with PMD.

sonar-runner.bat Unable to execute Sonar at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher .java:91)

I got the latest sonar-runner-dist-2.4 and sonarqube-4.3. Server starts fine, i can see the localhost But when i try to run the sonar-runner.bat -X, i see the below error. I looked at versions, logs but couldn't find the root-cause. Any help will be appreciated.
enter code here
MyProject>sonar-runner.bat -X
C:\sonar\sonar-runner-dist-2.4
SonarQube Runner 2.4
Java 1.6.0 IBM Corporation (32-bit)
Windows Vista 6.1 build 7601 Service Pack 1 x86
INFO: Error stacktraces are turned on.
INFO: Runner configuration file: C:\sonar\sonar-runner-dist-2.4\conf\sonar-runne
r.properties
INFO: Project configuration file: NONE
INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is
platform dependent)
INFO: Work directory: C:\cww\application\CWW_FSET_R0\online\aeEJB\.\.sonar
INFO: SonarQube Server 4.3
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 1.191s
Final Memory: 2M/5M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher
.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(AccessController.java:202
)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102
)
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at org.sonar.runner.Main.executeTask(Main.java:70)
at org.sonar.runner.Main.execute(Main.java:59)
at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.TypeNotPresentException: Type javax.annotation.CheckForNull
not present
at com.ibm.oti.reflect.AnnotationHelper.getAnnotation(AnnotationHelper.j
ava:38)
at com.ibm.oti.reflect.AnnotationHelper.getDeclaredAnnotations(Annotatio
nHelper.java:50)
at com.ibm.oti.reflect.Method.getDeclaredAnnotations(Method.java:31)
at java.lang.reflect.Method.getDeclaredAnnotations(Method.java:687)
at java.lang.reflect.AccessibleObject.getAnnotations(AccessibleObject.ja
va:186)
at com.ibm.oti.reflect.Method.getAnnotation(Method.java:20)
at java.lang.reflect.Method.getAnnotation(Method.java:677)
at org.picocontainer.injectors.AdaptingInjection.injectionAnnotated(Adap
tingInjection.java:230)
at org.picocontainer.injectors.AdaptingInjection.access$000(AdaptingInje
ction.java:46)
at org.picocontainer.injectors.AdaptingInjection$1.run(AdaptingInjection
.java:203)
at java.security.AccessController.doPrivileged(AccessController.java:202
)
at org.picocontainer.injectors.AdaptingInjection.injectionMethodAnnotate
d(AdaptingInjection.java:200)
at org.picocontainer.injectors.AdaptingInjection.methodAnnotatedInjectio
nAdapter(AdaptingInjection.java:171)
at org.picocontainer.injectors.AdaptingInjection.createComponentAdapter(
AdaptingInjection.java:70)
at org.picocontainer.behaviors.AbstractBehaviorFactory.createComponentAd
apter(AbstractBehaviorFactory.java:44)
at org.picocontainer.behaviors.OptInCaching.createComponentAdapter(OptIn
Caching.java:45)
at org.picocontainer.DefaultPicoContainer.addComponent(DefaultPicoContai
ner.java:535)
at org.picocontainer.DefaultPicoContainer.access$300(DefaultPicoContaine
r.java:83)
at org.picocontainer.DefaultPicoContainer$AsPropertiesPicoContainer.addC
omponent(DefaultPicoContainer.java:1148)
at org.sonar.api.platform.ComponentContainer.addComponent(ComponentConta
iner.java:175)
at org.sonar.api.platform.ComponentContainer.addSingleton(ComponentConta
iner.java:163)
at org.sonar.api.platform.ComponentContainer.add(ComponentContainer.java
:149)
at org.sonar.batch.bootstrap.BootstrapContainer.addBootstrapComponents(B
ootstrapContainer.java:83)
at org.sonar.batch.bootstrap.BootstrapContainer.doBeforeStart(BootstrapC
ontainer.java:77)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentCo
ntainer.java:90)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.
java:77)
at org.sonar.batch.bootstrapper.Batch.startBatch(Batch.java:92)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:74)
at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java
:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:599)
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher
.java:87)
... 9 more
Caused by: java.lang.ClassNotFoundException: javax.annotation.CheckForNull
at java.lang.Class.forName(Class.java:169)
at com.ibm.oti.reflect.AnnotationHelper.getAnnotation(AnnotationHelper.j
ava:33)
... 42 more
Here is my property file :
# required metadata
sonar.projectKey=my:MyProject
sonar.projectName=MyProject
sonar.projectVersion=1.0
# optional description
sonar.projectDescription=Any description
# path to source directories (required)
sonar.sources=src
# path to test source directories (optional)
#sonar.tests=testDir1,testDir2
# path to project binaries (optional), for example directory of Java bytecode
sonar.binaries=bin
# The value of the property must be the key of the language.
sonar.language=java
# Additional parameters
sonar.my.property=value
This issue seems to relate to the use of the IBM Java Virtual Machine : http://www-01.ibm.com/support/docview.wss?uid=swg1IZ76354. By using the Oracle one this should fix your issue.

Resources