dem*_*101 3 grails hibernate grails-orm
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
Run Code Online (Sandbox Code Playgroud)
Grails版本2.4.3(2.4.4),Java 1.7
BuillConfig:
runtime ':hibernate4:4.3.6.1'
runtime ":fixtures:1.3"
Run Code Online (Sandbox Code Playgroud)
配置:
grails.hibernate.pass.readonly = false
grails.hibernate.osiv.readonly = false
Run Code Online (Sandbox Code Playgroud)
在依赖项报告中,只有来自grails-plugin-databinding和hibernate4插件的Hibernate库
有任何想法吗?
如果你正在使用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
Run Code Online (Sandbox Code Playgroud)
然后选择要使用的那个,并在BuildConfig.groovy中选择v3和v4.他们只需要同步并且必须同意你想要使用的Hibernate版本.
但是这个类是一个Hibernate 3类,它不在Hibernate 4中,这意味着你要么使用Hibernate 3,要么有另一个依赖于Hibernate 3的插件.不幸的是,在所有流行的Hibernate相关插件之前还需要一段时间.有3.x和4.x的版本.