0

我正在尝试将我的 grails 应用程序连接到在本地运行的 DB2 数据库。当我想启动我的应用程序时,我收到多个错误?我只是开始使用 grails,甚至更多的是 DB2 数据库管理。有人可以帮我吗 ?

这是错误线索

    Message: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'org.h2.Driver' for connect URL 'jdbc:db2://localhost:50000/DTH3_E:currentSchema=DFP_V115'
   Line | Method
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask
|   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   908 | run      in     ''
^   662 | run . .  in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'org.h2.Driver' for connect URL 'jdbc:db2://localhost:50000/DTH3_E:currentSchema=DFP_V115'
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask
|   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   908 | run      in     ''
^   662 | run . .  in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'org.h2.Driver' for connect URL 'jdbc:db2://localhost:50000/DTH3_E:currentSchema=DFP_V115'
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask
|   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   908 | run      in     ''
^   662 | run . .  in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'org.h2.Driver' for connect URL 'jdbc:db2://localhost:50000/DTH3_E:currentSchema=DFP_V115'
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask
|   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   908 | run      in     ''
^   662 | run . .  in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'org.h2.Driver' for connect URL 'jdbc:db2://localhost:50000/DTH3_E:currentSchema=DFP_V115'
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask
|   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   908 | run      in     ''
^   662 | run . .  in java.lang.Thread
Caused by MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'org.h2.Driver' for connect URL 'jdbc:db2://localhost:50000/DTH3_E:currentSchema=DFP_V115'
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask
|   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   908 | run      in     ''
^   662 | run . .  in java.lang.Thread
Caused by SQLNestedException: Cannot create JDBC driver of class 'org.h2.Driver' for connect URL 'jdbc:db2://localhost:50000/DTH3_E:currentSchema=DFP_V115'
->> 1452 | createConnectionFactory in org.apache.commons.dbcp.BasicDataSource
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1371 | createDataSource in     ''
|   1044 | getConnection in     ''
|   303 | innerRun in java.util.concurrent.FutureTask$Sync
|   138 | run . .  in java.util.concurrent.FutureTask
|   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   908 | run . .  in     ''
^   662 | run      in java.lang.Thread
Caused by SQLException: No suitable driver
->> 264 | getDriver in java.sql.DriverManager
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1437 | createConnectionFactory in org.apache.commons.dbcp.BasicDataSource
|   1371 | createDataSource in     ''
|   1044 | getConnection in     ''
|   303 | innerRun in java.util.concurrent.FutureTask$Sync
|   138 | run      in java.util.concurrent.FutureTask
|   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   908 | run      in     ''
^   662 | run . .  in java.lang.Thread

在我的 datasource.groovy 文件中,这是我更改的内容:

environments {
    development {
        dataSource {
            dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
            //url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
            url = "jdbc:db2://localhost:50000/DTH3_E:currentSchema=DFP_V115"
        }
    }
....

通过一些研究,我了解到这是我的休眠配置。任何人都可以(in)验证吗?我下一步该去哪里……至少可以说很迷茫

如果想知道,数据库已启动并正在运行,我可以使用 DbVisualizer 连接到它。

在此先感谢您的帮助 !如果需要更多详细信息,请询问:) 我会尽量澄清问题。

4

1 回答 1

3

从您的异常中,Grails 正在尝试使用 H2 JDBC 驱动程序连接到您的 DB2 数据库。尝试在声明中指定 DB2 Hibernate 方言,dataSource看看它是否会使用正确的驱动程序:

dataSource {
    dialect="org.hibernate.dialect.DB2Dialect"
}

还要确保 Grails 项目中有必要的 DB2 jar。

于 2013-02-26T15:04:36.327 回答