Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error 500 during Sonar runner execution on Jenkins

I am getting the below error when running sonarqube standalone analysis on Jenkins. The sonarqube scanner is able to identify the files to be analyzed and is able to analyze them fine, but the issue is when it is trying to publish the project to dashboard.

When I open the URL http://vv123456:9000/api/ce/submit?projectKey=pkey&projectName=pname in browser, it says "{"errors":[{"msg":"HTTP method POST is required"}]}", which means the sonarqube webservice is fine.

Error on Jenkins build:

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: org.sonarqube.ws.client.HttpException: Error 500 on [http://vv123456:9000/api/ce/submit?projectKey=pkey&projectName=pname][1]
    at org.sonarqube.ws.client.BaseResponse.failIfNotSuccessful(BaseResponse.java:34)
    at org.sonar.batch.bootstrap.BatchWsClient.failIfUnauthorized(BatchWsClient.java:99)
    at org.sonar.batch.bootstrap.BatchWsClient.call(BatchWsClient.java:69)
    at org.sonar.batch.report.ReportPublisher.upload(ReportPublisher.java:172)
    at org.sonar.batch.report.ReportPublisher.execute(ReportPublisher.java:127)
    at org.sonar.batch.phases.PublishPhaseExecutor.publishReportJob(PublishPhaseExecutor.java:64)
    at org.sonar.batch.phases.PublishPhaseExecutor.executeOnRoot(PublishPhaseExecutor.java:51)
    at org.sonar.batch.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:86)
    at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
    at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:241)
    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:236)
    at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:226)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
    at org.sonar.batch.task.ScanTask.execute(ScanTask.java:47)
    at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
    at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:106)
    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119)
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:79)
    at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
    ... 9 more
like image 351
Prasann Avatar asked Jun 23 '16 16:06

Prasann


People also ask

What is sonar used for in Jenkins?

SonarQube enables developers to track code quality, which helps them to ascertain if a project is ready to be deployed in production. Further, it allows developers to continuously inspect the code, perform automatic reviews and run analysis to find code quality issues.

What is SonarQube runner?

SonarQube is an open-source automatic code review tool to detect bugs, vulnerabilities and code smell in your code.


1 Answers

I'm experiencing this problem too. Looking in the logs at /opt/sonar/logs/sonar.log I can see the following error:

Caused by: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (9122692 > 4194304). You can change this value on the server by setting the max_allowed_packet' variable.

Used advice from here https://dev.mysql.com/doc/refman/5.6/en/packet-too-large.html

and here

PacketTooBigException when running a sonar analysis

and here

http://codefabulae.blogspot.co.uk/2012/05/sonar-analysis-and-mysql-max-packet.html

The final solution was to write this in to my mysql config /etc/my.cnf:

[mysqld]
max_allowed_packet=32M

restart mysqld

sudo service mysqld restart

and check it via

mysql <insert user credentials here>
mysql> show variables like "max_allowed%";

and then reboot sonar

sudo service sonar restart

Then my build stopped having the 500 error as mentioned.

This is how to fix the issue PacketTooBig, which is a likely root cause.

like image 175
Ashley Frieze Avatar answered Nov 16 '22 04:11

Ashley Frieze