Cannot load JDBC driver class 'com.mysql.jdbc.Driver' sonar plugin jenkins

廉价感情. 提交于 2019-12-12 20:51:53

问题


I am using sonar plugin with jenkins. It always generates this error. It seems the plugin can't find the JDBC driver. I tried putting the JDBC driver in many possible places according to the many solutions I found in google, but it still generates this error.

C:\Jenkins\tools\hudson.plugins.sonar.SonarRunnerInstallation\sonar-runner-2.4
SonarQube Runner 2.4
Java 1.7.0_21 Oracle Corporation (32-bit)
Windows Server 2008 R2 6.1 x86
INFO: Runner configuration file: C:\Jenkins\tools\hudson.plugins.sonar.SonarRunnerInstallation\sonar-runner-2.4\conf\sonar-  runner.properties
INFO: Project configuration file: C:\Jenkins\jobs\check2\workspace\sonar-   project.properties
INFO: SonarQube Server 4.3.2
10:18:10.612 INFO  - Load batch settings
10:18:14.265 INFO  - User cache: C:\.sonar\cache
10:18:14.321 INFO  - Install plugins
10:18:18.941 INFO  - Install JDBC driver
10:18:18.971 INFO  - Create JDBC datasource for jdbc:mysql://localhost:3306/sonar
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 22.884s
Final Memory: 3M/15M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: Fail to connect to database
ERROR: Caused by: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
ERROR: Caused by: com.mysql.jdbc.Driver
ERROR: 
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
Build step 'Invoke Standalone Sonar Analysis' marked build as failure
Finished: FAILURE    

回答1:


I found the issue. It was in the sonar/conf/sonar.properties file (In sonarqube installation folder). Default url for database is wrong. I corrected it for mysql. Now it works fine. I spent days on this. Thanks TimHauschildt and SKempken.



来源:https://stackoverflow.com/questions/24503007/cannot-load-jdbc-driver-class-com-mysql-jdbc-driver-sonar-plugin-jenkins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!