问题描述:
使用Maven与SonarQube进行代码分析,完成分析后无法正常上传分析报告
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar (default-cli) on project qishi: Error 500 on http://sonar/api/ce/submit?projectKey=com.xxx:xxx&projectName=xxx : {"errors":[{"msg":"An error has occurred. Please contact your administrator"}]} -> [Help 1]
解决方案
- 1.查看SonarQube日志$sonar_home/logs/web.log,发现MySQL配置项max_allowed_packet的值过小
Caused by: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (12774723 > 4194304). You can change this value on the server by setting the max_allowed_packet' variable.at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3671)at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2508)at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2673)at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2549)at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861)
- 2.配置MySQLmax_allowed_packet并重启MySQL
mysqld --max_allowed_packet=500M
service mysqld restart
- 3.重启SonarQube
$sonar_home/bin/linux-x86-64/sonar.sh stop
$sonar_home/bin/linux-x86-64/sonar.sh start
一定要重启SonarQube,否则虽数据库配置已变更,但对SonarQube的数据库连接不会生效