Grails 2应用程序不会在JBOSS上部署:BeanCreationException [英] Grails 2 app wont deploy on JBOSS: BeanCreationException

查看:151
本文介绍了Grails 2应用程序不会在JBOSS上部署:BeanCreationException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将我的一个应用程序从Grails 1.3.7升级到2.1.0并安装了一些额外的插件之后,该应用程序将不再部署在用于生产的JBOSS AS 5.1上。
我从JBOSS服务器日志中得到的错误如下:

  13:39:10,263错误[[ /]]将上下文初始化事件发送到类的监听器实例的异常org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener 
org.springframework.beans.factory.BeanCreationException:创建名为'transactionManagerPostProcessor'的bean时出错:初始化豆失败了;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'transactionManager'的bean时出错:无法在设置bean属性'sessionFactory'时解析对bean'sessionFactory'的引用;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'sessionFactory'的bean时出错:init方法的调用失败;嵌套异常是java.lang.IncompatibleClassChangeError:找到类org.hibernate.cfg.Mappings,但期望的接口
在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
。在org.codehaus.groovy.grails.commons.spring.ReloadAwareAutowireCapableBeanFactory.doCreateBean(ReloadAwareAutowireCapableBeanFactory.java:126)
在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225 )
在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.j ava:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessor(AbstractApplicationContext.java:
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:449)
at org.codehaus.groovy.grails.commons.spring.DefaultRuntimeSpringConfiguration.getApplicationContext(DefaultRuntimeSpringConfiguration.java:
at org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:170)
at org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure( GrailsRuntimeConfigurator.java:127)
在org.codehaus.groovy.grails.web.context.GrailsConfigUtils.configureWebApplicationContext(GrailsConfigUtils.java:121)
在org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)$ b在org.codehaus.groovy.grails.web.context.GrailsContextLoader.initWebApplicationContext(GrailsContextLoader.java:104)
$ b at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3910)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4393)

为了解决我以前遇到的另一个问题(LifecycleException / ReflectionException:找不到方法addChild ...)我已经介绍了一个jboss-classloading.xml到我的WEB-INF目录中。在当前时刻,这有以下内容:

 < classloading xmlns =urn:jboss:classloading:1.0name = ROOT.wardomain =DefaultDomaintop-level-classloader =trueexport-all =NON_EMPTYimport-all =trueparent-first =false> < /类加载> 

我怀疑当前的问题也是类加载相关的,特别是因为我看到类问题是从JBOSS lib文件夹中加载的,而不是从war的lib文件夹中的jar中加载的:

  [Loaded org.hibernate。 cfg.Mappings from jar:file:/usr/local/jboss-5.1.0.GA/common/lib/hibernate-core.jar!/] 

显然,类org.hibernate.cfg.Mappings既存在于hibernate-core.jar中,也存在于应用程序的lib文件夹中(hibernate-core-3.6.10.Final.jar )。因此,我试图以不同的方式调整jboss-classloading.xml文件,以强制JBOSS从war文件中加载这个特定的类,但无论我做什么,我都会一直收到相同的错误在部署周期中)。

我的战争的WEB-INF / lib目录的完整内容:

  activation-1.1.jar google-collections.jar h2-1.3.164.jar sitemesh-2.4.jar 
antlr-2.7.7.jar grails-bootstrap-2.1.0.jar hamcrest-all-1.1.jar smartsprites-0.2.1.jar
aopalliance-1.0.jar grails-core-2.1.0.jar hibernate-commons-annotations-3.2.0.Final.jar spring-aop-3.1 .0.RELEASE.jar
asm-3.1.jar grails-crud-2.1.0.jar hibernate-core-3.6.10.Final.jar spring-asm-3.1.0.RELEASE.j ar
aspectjrt-1.6.10.jar grails-datastore-core-1.0.9.RELEASE.jar hibernate-ehcache-3.6.10.Final.jar spring-aspects-3.1.0.RELEASE.jar
aspectjweaver-1.6.10.jar grails-datastore-gorm-1.0.9.RELEASE.jar hibernate-jpa-2.0-api-1.0.1.Final.jar spring-beans-3.1.0.RELEASE.jar
avalon-framework-4.1.3.jar grails-datastore-simple-1.0.9.RELEASE.jar hibernate-validator-4.1.0.Final.jar spring-binding-2.0.8.RELEASE.jar
axis -1.4.jar grails-hibernate-2.1.0.jar javase-1.7.jar spring-context-3.1.0.RELEASE.jar
axis-jaxrpc-1.4.jar grails-logging-2.1.0.jar javassist -3.12.0.GA.jar spring-context-support-3.1.0.RELEASE.jar
axis-saaj-1.4.jar grails-plugin-codecs-2.1.0.jar javassist-3.7.ga.jar SPRI ng-core-3.1.0.RELEASE.jar
axis-wsdl4j-1.5.1.jar grails-plugin-controllers-2.1.0.jar jcaptcha-all-1.0-RC6.jar spring-expression-3.1。 0.RELEASE.jar
cas-client-core-3.2.1.jar grails-plugin-converters-2.1.0.jar jstl-1.1.2.jar spring-jdbc-3.1.0.RELEASE.jar
cglib-2.2.jar grails-plugin-datasource-2.1.0.jar jta-1.1.jar spring-jms-3.1.0.RELEASE.jar
commons-beanutils-1.8.3.jar grails- plugin-domain-class-2.1.0.jar jul-to-slf4j-1.6.2.jar spring-js-2.0.8.RELEASE.jar
commons-codec-1.5.jar grails-plugin-filters- 2.1.0.jar logkit-1.0.1.jar spring-orm-3.1.0.RELEASE.jar
commons-collections-3.2.1.jar grails-plugin-gsp-2.1.0.jar mail-1.4 .3.jar spring-test-3.1.0.RELEASE.jar
commons-dbcp-1.4.jar grails-plugin-i18n-2.1.0.jar mysql-connector-java-5.1.6.jar spring-tx-3.1。 0.RELEASE.jar
commons-discovery-0.2.jar grails-plugin-log4j-2.1.0.jar ognl-2.7.3.jar spring-web-3.1.0.RELEASE.jar
commons -el-1.0.jar grails-plugin-mimetypes-2.1.0.jar oro-2.0.8.jar spring-webflow-2.0.8.RELEASE.jar
commons-fileupload-1.2.2.jar grails- plugin-scaffolding-2.1.0.jar pjl-comp-filter-1.7.jar spring-webmvc-3.1.0.RELEASE.jar
commons-io-2.1.jar grails-plugin-services-2.1.0。 jar quartz-1.6.1.jar tomcat-catalina-ant-7.0.27.jar
commons-lang-2.6.jar grails-plugin-servlets-2.1.0.jar quartz-2.1.5.jar tomcat-embed-core-7.0.27.jar
commons-logging-1.1.jar grails-plugin-tomcat-2.1.0.jar selenium-java-client-driver-1.0.2.jar tomcat-embed- jasper-7.0.27.jar
commons-pool-1.5.6.jar grails-plugin-url-mappings-2.1.0.jar servlet-api-2.5.jar tomcat-embed-logging-juli-7.0。 27.jar
commons-validator-1.3.1.jar grails-plugin-validation-2.1.0.jar shiro-cas-1.2.0.jar tomcat-embed-logging-log4j-7.0.27.jar
concurrentlinkedhashmap-lru-1.2_jdk5.jar grails-resources-2.1.0.jar shiro-core-1.2.0.jar utils-0.0.2.jar
core-1.7.jar grails-spring-2.1 .0.jar shiro-ehcache-1.2.0.jar验证-api-1.0.0.GA.jar
dom4j-1.6.1.jar grails-web-2.1.0.jar shiro-quartz-1.2。 0.jar xpp3_min-1.1.4c.jar
ecj-3.6.2.jar grails-webflow-2.1.0.jar shiro-spring-1.2.0.jar yuicompressor-2.4.2.jar
ehcache-core -2.4.6.jar groovy-all-1.8.6.jar shiro-web-1.2.0.jar

有没有人有关于如何解决这个问题的想法?

解决方案

/ p>

http://grails.org/plugin/jbossas



文档位于:

http://grails-plugins.github.com/grails-jbossas/



这就是为什么发生这种情况:



https: //community.jboss.org/thread/156441



您需要配置用JBoss来排除Hibernate罐。 JBoss安装中通用/ lib中的JBoss Hibernate jar是首先加载的,而不是Grails Hibernate jar。这是一个类加载器命令/首选项问题。



一个非常肮脏的解决方案是删除common / lib下的jar或建议让类加载器工作以排除这些jar。 / p>

After having upgraded one of my apps from Grails 1.3.7 to 2.1.0 and installed a couple of additional plugins the app will no longer deploy on JBOSS AS 5.1, which is used for production. The error I am getting from the JBOSS server log is the following:

13:39:10,263 ERROR [[/]] Exception sending context initialized event to listener instance of class org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener
            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.IncompatibleClassChangeError: Found class org.hibernate.cfg.Mappings, but interface was expected
                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
                at org.codehaus.groovy.grails.commons.spring.ReloadAwareAutowireCapableBeanFactory.doCreateBean(ReloadAwareAutowireCapableBeanFactory.java:126)
                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
                at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
                at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
                at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
                at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
                at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:707)
                at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:449)
                at org.codehaus.groovy.grails.commons.spring.DefaultRuntimeSpringConfiguration.getApplicationContext(DefaultRuntimeSpringConfiguration.java:153)
                at org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:170)
                at org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:127)
                at org.codehaus.groovy.grails.web.context.GrailsConfigUtils.configureWebApplicationContext(GrailsConfigUtils.java:121)
                at org.codehaus.groovy.grails.web.context.GrailsContextLoader.initWebApplicationContext(GrailsContextLoader.java:104)
                at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
                at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3910)
                at org.apache.catalina.core.StandardContext.start(StandardContext.java:4393)

In order to resolve another issue I had earlier on( LifecycleException/ReflectionException: Cannot find method addChild...) I have introduced a jboss-classloading.xml into my WEB-INF directory. At the current moment this has the following contents:

<classloading xmlns="urn:jboss:classloading:1.0" name="ROOT.war" domain="DefaultDomain" top-level-classloader="true" export-all="NON_EMPTY" import-all="true" parent-first="false"> </classloading>

I suspect that the current issue is also class-loading related, especially since I see that the class in question is being loaded from JBOSS lib folder, and not from the jars in the war's lib folder:

 [Loaded org.hibernate.cfg.Mappings from jar:file:/usr/local/jboss-5.1.0.GA/common/lib/hibernate-core.jar!/]

Apparently the class org.hibernate.cfg.Mappings exists both in hibernate-core.jar as well as inside the app's lib folder(hibernate-core-3.6.10.Final.jar). I have therefore tried to tweak the jboss-classloading.xml file in different ways in order to force JBOSS to load this specific class from within the war file, but no matter what I do I keep getting the same error (or different ones much earlier in the deploy cycle).

The full contents of my war's WEB-INF/lib dir:

activation-1.1.jar                        google-collections.jar                     h2-1.3.164.jar                                 sitemesh-2.4.jar
antlr-2.7.7.jar                           grails-bootstrap-2.1.0.jar                 hamcrest-all-1.1.jar                           smartsprites-0.2.1.jar
aopalliance-1.0.jar                       grails-core-2.1.0.jar                      hibernate-commons-annotations-3.2.0.Final.jar  spring-aop-3.1.0.RELEASE.jar
asm-3.1.jar                               grails-crud-2.1.0.jar                      hibernate-core-3.6.10.Final.jar                spring-asm-3.1.0.RELEASE.jar
aspectjrt-1.6.10.jar                      grails-datastore-core-1.0.9.RELEASE.jar    hibernate-ehcache-3.6.10.Final.jar             spring-aspects-3.1.0.RELEASE.jar
aspectjweaver-1.6.10.jar                  grails-datastore-gorm-1.0.9.RELEASE.jar    hibernate-jpa-2.0-api-1.0.1.Final.jar          spring-beans-3.1.0.RELEASE.jar
avalon-framework-4.1.3.jar                grails-datastore-simple-1.0.9.RELEASE.jar  hibernate-validator-4.1.0.Final.jar            spring-binding-2.0.8.RELEASE.jar
axis-1.4.jar                              grails-hibernate-2.1.0.jar                 javase-1.7.jar                                 spring-context-3.1.0.RELEASE.jar
axis-jaxrpc-1.4.jar                       grails-logging-2.1.0.jar                   javassist-3.12.0.GA.jar                        spring-context-support-3.1.0.RELEASE.jar
axis-saaj-1.4.jar                         grails-plugin-codecs-2.1.0.jar             javassist-3.7.ga.jar                           spring-core-3.1.0.RELEASE.jar
axis-wsdl4j-1.5.1.jar                     grails-plugin-controllers-2.1.0.jar        jcaptcha-all-1.0-RC6.jar                       spring-expression-3.1.0.RELEASE.jar
cas-client-core-3.2.1.jar                 grails-plugin-converters-2.1.0.jar         jstl-1.1.2.jar                                 spring-jdbc-3.1.0.RELEASE.jar
cglib-2.2.jar                             grails-plugin-datasource-2.1.0.jar         jta-1.1.jar                                    spring-jms-3.1.0.RELEASE.jar
commons-beanutils-1.8.3.jar               grails-plugin-domain-class-2.1.0.jar       jul-to-slf4j-1.6.2.jar                         spring-js-2.0.8.RELEASE.jar
commons-codec-1.5.jar                     grails-plugin-filters-2.1.0.jar            logkit-1.0.1.jar                               spring-orm-3.1.0.RELEASE.jar
commons-collections-3.2.1.jar             grails-plugin-gsp-2.1.0.jar                mail-1.4.3.jar                                 spring-test-3.1.0.RELEASE.jar
commons-dbcp-1.4.jar                      grails-plugin-i18n-2.1.0.jar               mysql-connector-java-5.1.6.jar                 spring-tx-3.1.0.RELEASE.jar
commons-discovery-0.2.jar                 grails-plugin-log4j-2.1.0.jar              ognl-2.7.3.jar                                 spring-web-3.1.0.RELEASE.jar
commons-el-1.0.jar                        grails-plugin-mimetypes-2.1.0.jar          oro-2.0.8.jar                                  spring-webflow-2.0.8.RELEASE.jar
commons-fileupload-1.2.2.jar              grails-plugin-scaffolding-2.1.0.jar        pjl-comp-filter-1.7.jar                        spring-webmvc-3.1.0.RELEASE.jar
commons-io-2.1.jar                        grails-plugin-services-2.1.0.jar           quartz-1.6.1.jar                               tomcat-catalina-ant-7.0.27.jar
commons-lang-2.6.jar                      grails-plugin-servlets-2.1.0.jar           quartz-2.1.5.jar                               tomcat-embed-core-7.0.27.jar
commons-logging-1.1.jar                   grails-plugin-tomcat-2.1.0.jar             selenium-java-client-driver-1.0.2.jar          tomcat-embed-jasper-7.0.27.jar
commons-pool-1.5.6.jar                    grails-plugin-url-mappings-2.1.0.jar       servlet-api-2.5.jar                            tomcat-embed-logging-juli-7.0.27.jar
commons-validator-1.3.1.jar               grails-plugin-validation-2.1.0.jar         shiro-cas-1.2.0.jar                            tomcat-embed-logging-log4j-7.0.27.jar
concurrentlinkedhashmap-lru-1.2_jdk5.jar  grails-resources-2.1.0.jar                 shiro-core-1.2.0.jar                           utils-0.0.2.jar
core-1.7.jar                              grails-spring-2.1.0.jar                    shiro-ehcache-1.2.0.jar                        validation-api-1.0.0.GA.jar
dom4j-1.6.1.jar                           grails-web-2.1.0.jar                       shiro-quartz-1.2.0.jar                         xpp3_min-1.1.4c.jar
ecj-3.6.2.jar                             grails-webflow-2.1.0.jar                   shiro-spring-1.2.0.jar                         yuicompressor-2.4.2.jar
ehcache-core-2.4.6.jar                    groovy-all-1.8.6.jar                       shiro-web-1.2.0.jar

Does anyone have an idea about how to get around this issue?

解决方案

There is a plugins for this :)

http://grails.org/plugin/jbossas

The docs are located here:

http://grails-plugins.github.com/grails-jbossas/

This is why this is happenning:

https://community.jboss.org/thread/156441

You will need to configure JBoss to exclude the hibernate jars. The JBoss Hibernate jars that are in common/lib in the JBoss install are loading first, instead of the Grails Hibernate jars. This is a classloader order / preference issue.

A very dirty solution is to remove the jars under common/lib or as recommended get the classloader working to exclude those jars.

这篇关于Grails 2应用程序不会在JBOSS上部署:BeanCreationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆