本文介绍了Grails 2.4.0中有hibernate错误:3.6.10.15插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I created a new app using grails 2.4.0, then when changing the hibernate plugin to :hibernate:3.6.10.15, I got the following error:

    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期间运行s2-quickstart后出现的错误:2.0-RC3

Note : I have changed the hibernate plugin (from hibernate4:4.3.5.3 to hibernate:3.6.10.15) as a work around to solve an error apeared after running s2-quickstart during installing spring-security-core:2.0-RC3

这是在新版本中的一个错误,或者我错过了一些东西?

Is this a bug in the new release or I am missing something?

推荐答案

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
}

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

If you have enabled hibernate 3 in BuildConfig.groovy you should comment out cache of hibernate 4 in DataSource.groovy and enable cache of hibernate 3.

这篇关于Grails 2.4.0中有hibernate错误:3.6.10.15插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 23:34