GeoGriffin
GeoGriffin

Reputation: 1095

Sonar 2.13.1 with MySQL 5.1 Issue

We are new to Sonar and just downloaded v2.13.1 and got it up and working with our project. It was great until it started running slowly and I realized it was because we were still running on the included Derby. We are running MySQL Server 5.1 on the same box (along with TeamCity CI), so I followed the steps to setup MySQL.

The error line that follows mentions port 1527, which is referenced by the commented out Derby config lines.

    [14:11:31] [ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0:sonar (default-cli) on project my-project: Can not execute Sonar: PicoLifecycleException: method 'public final org.sonar.core.persistence.DefaultDatabase org.sonar.core.persistence.DefaultDatabase.start()', instance 'org.sonar.batch.bootstrap.BatchDatabase@1d4d6a, java.lang.RuntimeException: wrapper: Fail to connect to database: Cannot create PoolableConnectionFactory (java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused: connect.) -> [Help 1]

If I comment out the sonar.jdbc lines above and restore the following lines, then the both our "mvn clean install" and the "mvn sonar:sonar" complete successfully.

sonar.jdbc.url:                            jdbc:derby://localhost:152/sonar;create=true
sonar.jdbc.driverClassName:                org.apache.derby.jdbc.ClientDriver
sonar.jdbc.validationQuery:                values(1)

Is there a different configuration for the Maven target than what is used directly by the Sonar server? Is there an explicit way to tell which JDBC datasource is being connected to?

Upvotes: 2

Views: 6104

Answers (2)

Mark O'Connor
Mark O'Connor

Reputation: 78011

The Sonar server and your Maven client are configured separately.

Unless configured otherwise Maven will automatically assume that Sonar is running locally with a Derby database, explaining your errors.

The Sonar documentation explains how Maven can be configured to support MySQL.

Upvotes: 7

Valeriy
Valeriy

Reputation: 11

I faced with the similar problem yesterday (April, 11 2012) 1) input:

  • teamcity 7
  • maven 3.0.4
  • sonar 2.13
  • postgresql 9
  • global maven settings.xml contains sonar profile with proper DB settings
  • jdk 1.6.30
  • project build from command line passed ok

2) result:

  • teamcity - Can not execute Sonar
  • log contains exception

    Fail to connect to database: Cannot create PoolableConnectionFactory (java.net.ConnectException : Ошибка соединения с сервером localhost на порту 1527
    

3) possible cause:

  • TeamCity uses wrong settings.xml

4) solution:

  • goto Administratioin
  • goto left menu Integrations->Maven settings
  • upload your version of settings.xml (in my case with proper settings for Sonar)

Upvotes: 1

Related Questions