griffon-legacy / griffon-sonar-plugin

Sonar integration
Apache License 2.0
0 stars 0 forks source link

plugin seems to ignore jdbc config settings #1

Open gernotstarke opened 10 years ago

gernotstarke commented 10 years ago

I'm running a (Postgres-powered) sonar for several other projects - but fail to configure a griffon project to use this instance: (using griffon 1.4)

In BuildConfig.groovy I tried:

 sonar.host.url="http://localhost:9000"
 sonar.jdbc.url="jdbc:postgresql://localhost/sonar"
 sonar.jdbc.username="sonar"
 sonar.jdbc.password="sonar"

and

 sonar { host {url "http://localhost...}
            jdbc { url "jdbc:postgresql://....

but still 'griffon sonar' tries to use the default h2 database:

Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'org.h2.Driver' for connect URL 'jdbc:postgresql://localhost/sonar'

I couldn't find any running griffon sample with a postgres (or mysql) configured sonar plugin.

thx Gernot

gernotstarke commented 10 years ago

same happens if I try to configure via command line:

griffon -Dsonar.jdbc.url:'jdbc:postgresql://localhost/sonar' sonar -skip-tests

also fails:

 resolving dependencies... 
 Dependencies resolved in 379ms.
 Environment set to development 
 Resolving framework plugin dependencies ...
 Framework plugin dependencies resolved in 415 ms.
 Resolving plugin dependencies ...
 Plugin dependencies resolved in 1000 ms.
    [sonar] Apache Ant(TM) version 1.9.2 compiled on July 8 2013
    [sonar] Sonar Ant Task version: 2.1
    [sonar] Loaded from: file:/Users/gstarke/.ivy2/cache/org.codehaus.sonar-plugins/sonar-ant-task/jars/sonar-ant- task-2.1.jar
    [sonar] INFO: Default locale: "de_DE", source code encoding: "US-ASCII"
    [sonar] INFO: Work directory: /Users/gstarke/projects/pdfstamper/target/sonar
    [sonar] INFO: Sonar Server 4.0
    [sonar] 17:38:26.644 INFO  - Load batch settings
    [sonar] 17:38:26.721 INFO  - User cache: /Users/gstarke/.sonar/cache
    [sonar] 17:38:26.728 INFO  - Install plugins
    [sonar] 17:38:27.249 INFO  - Install JDBC driver
    [sonar] 17:38:27.258 INFO  - Create JDBC datasource for jdbc:postgresql://localhost/sonar
 : org.sonar.runner.impl.RunnerException: Unable to execute Sonar
    at org.codehaus.griffon.cli.GriffonScriptRunner.executeWithGantInstance(GriffonScriptRunner.java:648)
    at   org.codehaus.griffon.cli.GriffonScriptRunner.executeWithGantInstanceNoException(GriffonScriptRunner.java:667)
    at org.codehaus.griffon.cli.GriffonScriptRunner.callPluginOrGriffonScript(GriffonScriptRunner.java:392)
    at org.codehaus.griffon.cli.GriffonScriptRunner.doExecuteCommand(GriffonScriptRunner.java:303)
    at org.codehaus.griffon.cli.GriffonScriptRunner.main(GriffonScriptRunner.java:141)
    at org.codehaus.griffon.cli.support.GriffonStarter.rootLoader(GriffonStarter.java:198)
    at org.codehaus.griffon.cli.support.GriffonStarter.main(GriffonStarter.java:223)
 Caused by: : org.sonar.runner.impl.RunnerException: Unable to execute Sonar
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:116)
    at _GriffonSettings.runSonar(_GriffonSettings:109)
    at _GriffonSettings.this$4$runSonar(_GriffonSettings)
    at _GriffonSettings$_run_closure1.doCall(_GriffonSettings:29)
    ... 7 more
 Caused by: org.sonar.runner.impl.RunnerException: Unable to execute Sonar
    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:79)
    at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:63)
    at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:57)
    at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
    at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:71)
    at org.sonar.runner.api.Runner.execute(Runner.java:89)
    at org.sonar.ant.SonarTask.launchAnalysis(SonarTask.java:53)
    at org.sonar.ant.SonarTask.execute(SonarTask.java:48)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    ... 10 more
 Caused by: java.lang.IllegalStateException: Fail to connect to database
    at org.sonar.core.persistence.DefaultDatabase.start(DefaultDatabase.java:81)
    at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110)
    at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89)
    at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84)
    at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169)
    at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132)
    at org.picocontainer.behaviors.Stored.start(Stored.java:110)
    at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1015)
    at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1008)
    at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:766)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:91)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.bootstrapper.Batch.startBatch(Batch.java:92)
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:74)
    at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:45)
    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:75)
    ... 19 more
 Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'org.h2.Driver' for  connect URL 'jdbc:postgresql://localhost/sonar'
    at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1452)
    at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
    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)
    ... 34 more
 Caused by: java.sql.SQLException: No suitable driver
    at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1437)
    ... 39 more
aalmiray commented 10 years ago

Did you try defining a driver entry too? For example

griffon.project.dependency.resolution = {
    inherits "global"
    log "warn"
    repositories {
        griffonHome()
        jcenter()
    }
    dependencies {
        build 'org.postgresql:postgresql:9.3-1100-jdbc41'
    }
}

sonar.jdbc.url =             'jdbc:postgresql://localhost/sonar'
sonar.jdbc.driverClassName = 'org.postgresql.Driver'
gernotstarke commented 10 years ago

thanx Andrés, at least it solved ONE problem...:

I'm on the latest SonarQube 4.0., running Groovy 2.1.7 on Java-7

thx for your patience and help - very much appreciated!

org.sonar.runner.impl.RunnerException: Unable to execute Sonar at org.codehaus.griffon.cli.GriffonScriptRunner.executeWithGantInstance(GriffonScriptRunner.java:648) at org.codehaus.griffon.cli.GriffonScriptRunner.executeWithGantInstanceNoException(GriffonScriptRunner.java:667) at org.codehaus.griffon.cli.GriffonScriptRunner.callPluginOrGriffonScript(GriffonScriptRunner.java:392) at org.codehaus.griffon.cli.GriffonScriptRunner.doExecuteCommand(GriffonScriptRunner.java:303) at org.codehaus.griffon.cli.GriffonScriptRunner.main(GriffonScriptRunner.java:141) at org.codehaus.griffon.cli.support.GriffonStarter.rootLoader(GriffonStarter.java:198) at org.codehaus.griffon.cli.support.GriffonStarter.main(GriffonStarter.java:223) Caused by: : org.sonar.runner.impl.RunnerException: Unable to execute Sonar at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:116) at _GriffonSettings.runSonar(_GriffonSettings:109) at _GriffonSettings.this$4$runSonar(_GriffonSettings) at _GriffonSettings$_run_closure1.doCall(_GriffonSettings:29) ... 7 more Caused by: org.sonar.runner.impl.RunnerException: Unable to execute Sonar at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:79) at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:63) at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:57) at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50) at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:71) at org.sonar.runner.api.Runner.execute(Runner.java:89) at org.sonar.ant.SonarTask.launchAnalysis(SonarTask.java:53) at org.sonar.ant.SonarTask.execute(SonarTask.java:48) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) ... 10 more Caused by: java.lang.NoSuchMethodError: org.sonar.plugins.surefire.api.SurefireUtils.getReportsDirectory(Lorg/sonar/api/resources/Project;)Ljava/io/File; at org.sonar.plugins.groovy.surefire.SurefireSensor.analyse(SurefireSensor.java:51) at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:72) at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:114) at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:150) at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92) at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77) at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:190) at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:185) at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:178) at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92) at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77) at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:58) at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45) at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:82) at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92) at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77) at org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapContainer.java:155) at org.sonar.batch.bootstrap.BootstrapContainer.doAfterStart(BootstrapContainer.java:143) at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92) at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77) at org.sonar.batch.bootstrapper.Batch.startBatch(Batch.java:92) at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:74) at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:45) at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:75) ... 19 more

aalmiray commented 10 years ago

Hmm this looks like an incompatible API change in recent Sonar releases as pointed out by the deepest cause

Caused by: java.lang.NoSuchMethodError: org.sonar.plugins.surefire.api.SurefireUtils.getReportsDirectory(Lorg/sonar/api/resources/Project;)Ljava/io/File;
 at org.sonar.plugins.groovy.surefire.SurefireSensor.analyse(SurefireSensor.java:51)

Could it be the case that the Groovy plugin for Sonar is outdated? Or is a newer version of sonar-ant-task needed (latest published release is 2.1 since 228 days ago)? I do remember testing the plugin in late July, this must have been against SonarQube 3.7.x so maybe there are some changes in 4.x that may trigger this error. I believe this problem should be posted at the Sonar mailing list (http://www.sonarqube.org/get-support/).