1

在将 grails 应用程序从 1.3.7 升级到 2.0 之后,将抛出 java NullPointerException(完整错误如下)。

我正在使用 debian squeeze 和 java 版本 OpenJDK“1.6.0_18”,尽管也尝试过使用预打包的 debian sun-jdk。

我试图卸载所有插件,但没有成功;调试模式也没有给我任何线索。我还在开发环境中检查了我的数据源:

dataSource {
    pooled = true
    driverClassName = "com.mysql.jdbc.Driver"
    dialect = org.hibernate.dialect.MySQLInnoDBDialect
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
environments {
    development {
        dataSource {

        dbCreate = "create-drop" // one of 'create', 'create-drop','update'
    //url = "jdbc:hsqldb:mem:devDB"  //hsql
        url = "jdbc:mysql://server.domain/database" //mysql
        username = "user"
        password = "password"

    }
}

一点运气都没有……有什么想法吗?我检查了相关的帖子,但在这里找不到相同的问题...

提前致谢

Error 2012-02-07 13:24:15,024 [Thread-11] 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': Invocation of init method failed; nested exception is     java.lang.NullPointerException
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': Invocation of init method failed; nested exception is     java.lang.NullPointerException
    Line | Method
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    636 | 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': Invocation of init method failed; nested exception is     java.lang.NullPointerException
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    636 | run . . . in java.lang.Thread

Caused by BeanCreationException: Error creating bean with name 'sessionFactory':     Invocation of init method failed; nested exception is java.lang.NullPointerException
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    636 | run . . . in java.lang.Thread

Caused by NullPointerException: null
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    636 | run . . . in java.lang.Thread
4

3 回答 3

2

只是为了关闭这个问题,它与 acegi-plugin 的 spring-security-plugin ugprade 有关。我使用了 spring-security-plugin 默认类和属性,一切正常。

于 2012-07-23T18:40:42.560 回答
0

检查您的 BuildConfig.groovy 确保已启用适当的 JDBC 库,例如在这些行中编写的:

依赖项{运行时'mysql:mysql-connector-java:5.1.16'}

或者,如果您更喜欢在不依赖 Grails 加载库机制的情况下添加库,只需将您的 jar 放入项目的 /lib 文件夹即可

于 2012-03-12T16:18:58.643 回答
0

protected通过在 .groovy 域类中使用 Java 关键字,我收到了类似的错误。我刚刚删除了protected关键字,它工作正常。我想如果我将文件重命名为.java,它也可以正常工作。

于 2012-09-26T18:34:02.960 回答