senatori
senatori

Reputation: 98

Analysis fails on SonarQube 4.1 with java.sql.SQLException but succeeds on 4.5

Running sonar-runner on a sonar-example project against my SonarQube 4.1 instance fails. In the stack trace, I noticed that it gives the following error:

Caused by: java.sql.SQLException: Access denied for user 'sonar'@'172.23.48.129'

That ip is my local machines IP. My SonarQube server is on a different box.

My sonar-runner.properties and sonar-project.properties file does not have jdbc set to that IP(or a hostname that resolves to that IP) anywhere. Even the INFO level log bellow will testify to that.

What's strange is that I can run sonar-runner on the same sample project while pointing to a test instance of SonarQube 4.5 and the analysis runs successfully.

It errors out and give the following output:

sonar-runner -X
SonarQube Runner 2.4
Java 1.7.0_79 Oracle Corporation (64-bit)
Mac OS X 10.10.3 x86_64
INFO: Error stacktraces are turned on.
INFO: Runner configuration file: /Users/senatori/Documents/sonar-runner-2.4/conf/sonar-runner.properties
INFO: Project configuration file: /Users/senatori/Documents/sonar-examples/projects/languages/groovy/groovy-sonar-runner/sonar-project.properties
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Work directory: /Users/senatori/Documents/sonar-examples/projects/languages/groovy/groovy-sonar-runner/./.sonar
INFO: SonarQube Server 4.1.1
18:10:05.102 INFO  - Load batch settings
18:10:05.121 DEBUG - Download: http://sonar.redac.dev/batch_bootstrap/properties?dryRun=false (no proxy)
18:10:05.298 INFO  - User cache: /Users/senatori/.sonar/cache
18:10:05.311 INFO  - Install plugins
18:10:05.311 DEBUG - Download index of plugins
18:10:05.311 DEBUG - Download: http://sonar.redac.dev/deploy/plugins/index.txt (no proxy)
18:10:05.648 INFO  - Install JDBC driver
18:10:05.648 DEBUG - Download index of jdbc-driver
18:10:05.648 DEBUG - Download: http://sonar.redac.dev/deploy/jdbc-driver.txt (no proxy)
18:10:05.699 INFO  - Create JDBC datasource for jdbc:mysql://sonardb001.redac.dev:3306/sonar?useUnicode=true&characterEncoding=utf8
18:10:06.282 DEBUG - To prevent a memory leak, the JDBC Driver [com.mysql.jdbc.Driver] has been forcibly deregistered
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 2.173s
Final Memory: 9M/123M
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:

omitted some of the stack trace for clarity

Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'sonar'@'172.23.48.129' (using password: YES))
at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
at org.apache.commons.dbcp.BasicDataSource.getLogWriter(BasicDataSource.java:1098)
at org.apache.commons.dbcp.BasicDataSourceFactory.createDataSource(BasicDataSourceFactory.java:350)
at org.sonar.core.persistence.DefaultDatabase.initDatasource(DefaultDatabase.java:142)
at org.sonar.core.persistence.DefaultDatabase.start(DefaultDatabase.java:75)
... 32 more
Caused by: java.sql.SQLException: Access denied for user 'sonar'@'172.23.48.129' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4190)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4122)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:927)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1709)

Any idea why it's doing that? Thanks

Upvotes: 0

Views: 257

Answers (1)

Mithfindel
Mithfindel

Reputation: 4708

The message Access denied for user 'sonar'@'172.23.48.129' is telling you that the user sonar cannot connect to the database schema of your SonarQube 4.1 instance from your machine (with IP address 172.23.48.129).

Please check permissions for this schema, for smooth operations you should have something like:

GRANT USAGE ON `sonar`.<your sonar db> TO 'sonar'@'%' IDENTIFIED BY PASSWORD '*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' 
GRANT ALL PRIVILEGES ON `sonar`.<your sonar db> TO 'sonar'@'%'

... or some relevant IP address range instead of '%'.

Upvotes: 1

Related Questions