2

我对 grails 有点陌生,但是当我尝试运行我的项目时它失败了,我得到了以下堆栈跟踪:

| Loading Grails 2.0.4
| Configuring classpath.
| Environment set to development.....
| Packaging Grails application....
| Compiling 1 source files..
| Compiling 1 source files.....
| Running Grails application
| Error 2013-06-26 14:01:37,372 [pool-7-thread-1] ERROR context.GrailsContextLoader  - Error executing bootstraps: 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 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': 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 PoolableConnectionFactory (Unable to initialize driver properties due to java.lang.IllegalAccessException: Class com.springsource.loaded.ri.ReflectiveInterceptor can not access a member of class com.mysql.jdbc.ConnectionPropertiesImpl with modifiers "private")
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 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': 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 PoolableConnectionFactory (Unable to initialize driver properties due to java.lang.IllegalAccessException: Class com.springsource.loaded.ri.ReflectiveInterceptor can not access a member of class com.mysql.jdbc.ConnectionPropertiesImpl with modifiers "private")
    Line | Method
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | 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 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': 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 PoolableConnectionFactory (Unable to initialize driver properties due to java.lang.IllegalAccessException: Class com.springsource.loaded.ri.ReflectiveInterceptor can not access a member of class com.mysql.jdbc.ConnectionPropertiesImpl with modifiers "private")
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run . . . in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': 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 PoolableConnectionFactory (Unable to initialize driver properties due to java.lang.IllegalAccessException: Class com.springsource.loaded.ri.ReflectiveInterceptor can not access a member of class com.mysql.jdbc.ConnectionPropertiesImpl with modifiers "private")
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run . . . in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'lobHandlerDetector': 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 PoolableConnectionFactory (Unable to initialize driver properties due to java.lang.IllegalAccessException: Class com.springsource.loaded.ri.ReflectiveInterceptor can not access a member of class com.mysql.jdbc.ConnectionPropertiesImpl with modifiers "private")
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run . . . in java.lang.Thread
Caused by MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Unable to initialize driver properties due to java.lang.IllegalAccessException: Class com.springsource.loaded.ri.ReflectiveInterceptor can not access a member of class com.mysql.jdbc.ConnectionPropertiesImpl with modifiers "private")
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run . . . in java.lang.Thread
Caused by SQLNestedException: Cannot create PoolableConnectionFactory (Unable to initialize driver properties due to java.lang.IllegalAccessException: Class com.springsource.loaded.ri.ReflectiveInterceptor can not access a member of class com.mysql.jdbc.ConnectionPropertiesImpl with modifiers "private")
->> 1549 | createPoolableConnectionFactory in org.apache.commons.dbcp.BasicDataSource
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1388 | createDataSource in     ''
|   1044 | getConnection in     ''
|    334 | innerRun  in java.util.concurrent.FutureTask$Sync
|    166 | run . . . in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run       in java.lang.Thread
Caused by SQLException: Unable to initialize driver properties due to java.lang.IllegalAccessException: Class com.springsource.loaded.ri.ReflectiveInterceptor can not access a member of class com.mysql.jdbc.ConnectionPropertiesImpl with modifiers "private"
->> 1073 | createSQLException in com.mysql.jdbc.SQLError
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    987 | createSQLException in     ''
|    982 | createSQLException in     ''
|    927 | createSQLException in     ''
|   2772 | initializeProperties in com.mysql.jdbc.ConnectionPropertiesImpl
|   3312 | initializeDriverProperties in com.mysql.jdbc.ConnectionImpl
|    786 | <init> .  in     ''
|     47 | <init>    in com.mysql.jdbc.JDBC4Connection
|    411 | handleNewInstance in com.mysql.jdbc.Util
|    381 | getInstance in com.mysql.jdbc.ConnectionImpl
|    305 | connect . in com.mysql.jdbc.NonRegisteringDriver
|     38 | createConnection in org.apache.commons.dbcp.DriverConnectionFactory
|    582 | makeObject in org.apache.commons.dbcp.PoolableConnectionFactory
|   1556 | validateConnectionFactory in org.apache.commons.dbcp.BasicDataSource
|   1545 | createPoolableConnectionFactory in     ''
|   1388 | createDataSource in     ''
|   1044 | getConnection in     ''
|    334 | innerRun  in java.util.concurrent.FutureTask$Sync
|    166 | run . . . in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run       in java.lang.Thread

谁能帮我弄清楚这里可能存在什么问题?我记得它以前工作过,我尝试了一个新的 STS-grails 安装

数据源.groovy

dataSource {
        pooled = true
        driverClassName = "com.mysql.jdbc.Driver"
        dialect = "org.hibernate.dialect.MySQL5InnoDBDialect"
}

hibernate {
        cache.use_second_level_cache = true
        cache.use_query_cache = false
        cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
environments {
        //    development {
        //        dataSource {
        //            dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
        //            url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
        //        }
        //    }

        development {
                dataSource {

                        pooled = true

                        dbCreate = "create" // one of 'create', 'create-drop','update'
                        url = "jdbc:mysql://localhost/mydatabase?useUnicode=yes&characterEncoding=UTF-8"
                        username = "root"
                        password = "root"

                        properties {
                                maxActive = 50
                                maxIdle = 25
                                minIdle = 5
                                initialSize = 5
                                minEvictableIdleTimeMillis = 1800000
                                timeBetweenEvictionRunsMillis = 1800000
                                maxWait = 10000
                         }

                }
        }
}
4

2 回答 2

11

这可能是 Spring-Loaded 重载代理的问题。

尝试使用noreloading标志禁用它

YOUR_GRAILS_COMMAND_HERE -noreloading

还要检查 JIRA 问题以获取潜在的错误修复等。

于 2013-06-26T12:36:27.233 回答
4

遇到同样的问题,即使使用 -noreloading 也无法解决,我发现这可能是与 JDK 版本相关的问题:它显示使用 jdk1.7.0_25 而使用 JDK 1.6 或以前的 JDK 1.7 版本不会发生,如https://dba.stackexchange.com/questions/45029/mysql-exception-after-upgrading-from-java-6-to-java-7

于 2013-07-04T12:25:19.813 回答