Sonar 2.4的跑步者一直在寻找org.h2.Driver

时间:2015-08-31 22:57:55

标签: sonarqube sonar-runner

我已成功配置声纳服务器(5.1.2)在Windows上运行MSSQL。在sonarQube配置文件 soar.properties 中,我只使用

sonar.jdbc.url=jdbc:jtds:sqlserver://localhost/sonar;instance=MM02;user=sonar;password=sonar;SelectMethod=Cursor

并且在跑步者文件夹 sonar-runner-2.4 中,sonar-runner.properties已经

sonar.jdbc.url=jdbc:jtds:sqlserver://localhost/sonar;instance=MM02;SelectMethod=Cursor

其他连接字符串都已注释掉。 我的sonar-project.properties文件中没有连接字符串。

然而,当我在CL中启动跑步者时,我不断收到错误"无法加载JDBC驱动程序类' org.h2.Driver'。

堆栈跟踪如下:

15:40:33.052 INFO  - Create JDBC datasource for jdbc:h2:tcp://localhost/sonar
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 1.185s
Final Memory: 8M/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: java.lang.IllegalStateException: Fail to connect to database
        at org.sonar.core.persistence.DefaultDatabase.start(DefaultDatabase.java
:77)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(
ReflectionLifecycleStrategy.java:110)
    at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(Reflect
ionLifecycleStrategy.java:89)
        at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter
.start(AbstractInjectionFactory.java:84)
        at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.j
ava:169)
        at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Store
d.java:132)
        at org.picocontainer.behaviors.Stored.start(Stored.java:110)
        at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(Defaul
tPicoContainer.java:1015)
        at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoConta
iner.java:1008)
        at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.jav
a:766)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentCo
ntainer.java:91)
        at org.sonar.batch.bootstrapper.Batch.start(Batch.java:81)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
        at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java
:48)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher
.java:87)
        ... 9 more
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver c
lass 'org.h2.Driver'
        at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(Basic
DataSource.java:1429)
        at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSou
rce.java:1371)
        at org.apache.commons.dbcp.BasicDataSource.getLogWriter(BasicDataSource.
java:1098)
        at org.apache.commons.dbcp.BasicDataSourceFactory.createDataSource(Basic
DataSourceFactory.java:350)
        at org.sonar.core.persistence.DefaultDatabase.initDatasource(DefaultData
base.java:103)
        at org.sonar.core.persistence.DefaultDatabase.start(DefaultDatabase.java
:72)
        ... 31 more
Caused by: java.lang.ClassNotFoundException: org.h2.Driver
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(Basic
DataSource.java:1420)
    ... 36 more

为什么这个运行器加载h2驱动程序,尽管配置表明MSSQL是数据库?

1 个答案:

答案 0 :(得分:1)

我遇到了运行Sonar Runner的MSBuild版本的同样问题。我能够通过将这两行添加到SonarQube.Analysis.xml文件以及sonar.jdbc.url来修复它:

<Property Name="sonar.jdbc.username">sonar</Property>
<Property Name="sonar.jdbc.password">sonar</Property>

所以在你的情况下:

sonar.jdbc.username=sonar
sonar.jdbc.password=sonar