spring - 带有休眠 :3. 6.10.15 插件的 grails 2.4.0 中的错误

标签 spring security grails

我使用 grails 2.4.0 创建了一个新应用程序,然后将 hibernate 插件更改为 :hibernate:3.6.10.15 时,出现以下错误:

    Error |
2014-05-25 12:37:52,167 [localhost-startStop-1] ERROR context.Grail
actionManagerPostProcessor': Initialization of bean failed; nested
e 'transactionManager': Cannot resolve reference to bean 'sessionFa
.factory.BeanCreationException: Error creating bean with name 'sess
n: could not instantiate RegionFactory [org.hibernate.cache.ehcache
Message: Error creating bean with name 'transactionManagerPostProce
eationException: Error creating bean with name 'transactionManager'
nested exception is org.springframework.beans.factory.BeanCreationE
 exception is org.hibernate.HibernateException: could not instantia
    Line | Method
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Wor
^    744 | run       in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'tra
essionFactory'; nested exception is org.springframework.beans.facto
d failed; nested exception is org.hibernate.HibernateException: cou
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Wor
^    744 | run       in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'ses
on: could not instantiate RegionFactory [org.hibernate.cache.ehcach
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Wor
^    744 | run       in java.lang.Thread
Caused by HibernateException: could not instantiate RegionFactory [
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Wor
^    744 | run       in java.lang.Thread
Caused by ClassNotFoundException: org.hibernate.cache.ehcache.EhCac
->>  366 | run       in java.net.URLClassLoader$1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|    355 | run       in     ''
|    354 | findClass in java.net.URLClassLoader
|    425 | loadClass in java.lang.ClassLoader
|    190 | forName . in java.lang.Class
|    262 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Wor
^    744 | run . . . in java.lang.Thread
| Error Forked Grails VM exited with error

注意:我已将 hibernate 插件(从 hibernate4:4.3.5.3 更改为 hibernate:3.6.10.15)作为解决在安装 spring-security-core:2.0-RC3 期间运行 s2-quickstart 后出现的错误的解决方法

这是新版本中的错误还是我遗漏了什么?

最佳答案

您的 conf/DataSource.groovy 休眠部分应如下所示:

hibernate {
  cache.use_second_level_cache = true
  cache.use_query_cache = false
  cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
//cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
  singleSession = true // configure OSIV singleSession mode
}

如果您在 BuildConfig.groovy 中启用了 hibernate 3,您应该在 DataSource.groovy 中注释掉 hibernate 4 的缓存并启用 hibernate 3 的缓存。

关于spring - 带有休眠 :3. 6.10.15 插件的 grails 2.4.0 中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23854730/

相关文章:

spring - EhCache CacheManager 具有多个 EntityManagerFactory

java - 仅当从某个类调用该方法时才拦截该方法?

grails - Grails-为什么setDateCreated被多次调用?

grails - 由于缺少方法而无法设置脚手架

mysql - Grails:Joda LocalDate 作为 MySQL 数据库中的唯一键

java - Spring注解-java.lang.IllegalArgumentException : 'sessionFactory' or 'hibernateTemplate' is required in spring+hibernate

java - 从另一个项目加载 AnnotationConfigApplicationContext[Eclipse]

python - Flask 安全休息 API

security - CouchDB 中的基本 HTTP 身份验证对于跨 EC2 区域的复制是否足够安全?

ios - 数据保护 - iPhone