在Glassfish 4上部署Grails应用程序时出错

在Glassfish 4上部署Grails应用程序时出错,grails,glassfish,Grails,Glassfish,我正在尝试在Glassfish 4上部署Grails应用程序,但失败并出现以下错误: Exception Occurred :Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframe

我正在尝试在Glassfish 4上部署Grails应用程序,但失败并出现以下错误:

Exception Occurred :Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: 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 org.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level cache is used in the application, but property hibernate.cache.region.factory_class is not given; please either disable second level cache or set correct region factory using the hibernate.cache.region.factory_class setting and make sure the second level cache provider (hibernate-infinispan, e.g.) is available on the classpath.. Please see server.log for more details.]]

我无法找出导致此错误的原因,我在google上尝试过,但没有任何用处

错误的根本原因与hibernate缓存配置有关:

Invocation of init method failed; nested exception is org.hibernate.cache.NoCacheRegionFactoryAvailableException:
Second-level cache is used in the application, but property hibernate.cache.region.factory_class is not given;
please either disable second level cache or set correct region factory using the hibernate.cache.region.factory_class setting and make sure the second level cache provider (hibernate-infinispan, e.g.) is available on the classpath..

我建议查看/比较缓存设置并检查缓存提供程序。

数据源中。groovy
注释了整个文件中的
driverClassName
方言
,在
production
部分中,我对
URL
进行了注释,并使用
URL
代替
jndiName
,并成功地部署在GlassFish上,没有先前的错误。希望此解决方法能帮助其他人

我没有在
数据源
文件中更改任何内容,仅更改数据库的配置,这是缓存的一部分
cache.use\u second\u level\u cache=true cache.use\u query\u cache=false cache.region.factory\u class='org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory'//hibernate 4singleSession=true//配置OSIV singleSession mode flush.mode='manual'//OSIV session flush mode在事务上下文之外
因此,您使用的是二级缓存。您可以尝试通过设置cache.use_second_level_cache=false或删除所有缓存属性来关闭它。如果你真的想使用二级缓存,你必须正确地配置它,例如,我没有向这部分添加任何东西,这部分内容是由grails生成的,我在文件中对缓存块进行了注释,并尝试再次部署,但仍然得到相同的错误。