Grails更新2.3.11-> 2.4.3 ClassNotFoundException:org.hibernate.cache.access.AccessType

时间:2014-10-28 16:21:29

标签: hibernate grails gorm

Grails更新后,我遇到以下异常:

2014-10-28 17:12:27,651 [localhost-startStop-1] ERROR context.GrailsContextLoaderListener  - Error initializing the application: 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.NoClassDefFoundError: org/hibernate/cache/access/AccessType
org.springframework.beans.factory.BeanCreationException: 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.NoClassDefFoundError: org/hibernate/cache/access/AccessType
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: 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.NoClassDefFoundError: org/hibernate/cache/access/AccessType
    ... 4 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cache/access/AccessType
    ... 4 more
Caused by: java.lang.NoClassDefFoundError: org/hibernate/cache/access/AccessType
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2615)
    at java.lang.Class.privateGetPublicMethods(Class.java:2733)
    at java.lang.Class.getMethods(Class.java:1472)
    ... 4 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.cache.access.AccessType
    at org.codehaus.groovy.tools.RootLoader.findClass(RootLoader.java:175)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:147)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 7 more

Grails版本2.4.3(2.4.4),Java 1.7

BuillConfig:

runtime ':hibernate4:4.3.6.1'
runtime ":fixtures:1.3"

配置:

grails.hibernate.pass.readonly = false
grails.hibernate.osiv.readonly = false

在依赖项报告中,只有来自grails-plugin-databinding&的Hibernate库。 hibernate4插件

有什么想法吗?

1 个答案:

答案 0 :(得分:5)

如果您正在使用Hibernate 4,则您的DataSource.groovy可能配置错误。在新的2.4.x应用中,您会在hibernate section

中看到这一点
//  cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4

然后选择要使用的那个,并在BuildConfig.groovy中选择v3和v4。他们只需要同步,并且必须同意你想要使用的Hibernate版本。

但是那个类是一个Hibernate 3类,它不在Hibernate 4中,这暗示你要么使用Hibernate 3,要么有另一个依赖于Hibernate 3的插件。不幸的是它会成为所有流行的与Hibernate相关的插件都有3.x和4.x的版本。