tags:

views:

31

answers:

1

I have a scenario where we deployed two EAR's on JBoss4.2.3. Each Ear has its own applicationContext defined. But I realized while debugging, one application bean definitions overriding the other.

Here is the server log:

09:23:23,962 INFO [XmlWebApplicationContext] Refreshing org.springframework.web.context.support.XmlWebApplicationContext@1b4aee4: display name [Root WebApplicationContext]; startup date [Thu Jul 08 09:23:23 MDT 2010]; root of context hierarchy 09:23:24,103 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext-idp.xml] 09:23:24,166 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from URL [jar:file:/C:/jboss-4.2.3.GA/server/default/tmp/deploy/tmp608645178333044413IDP.ear-contents/IDPEJB.jar!/META-INF/applicationContext.xml] 09:23:24,181 INFO [XmlWebApplicationContext] Bean factory for application context [org.springframework.web.context.support.XmlWebApplicationContext@1b4aee4]: org.springframework.beans.factory.support.DefaultListableBeanFactory@8478d0 09:23:24,384 INFO [DefaultListableBeanFactory] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@8478d0: defining beans [powersuiteServiceFactory,url,qname,powersuiteService,IDPDocumentumServiceFactory,documentumServiceForIDP,applicationUserName,IDPApplicationContextProvider,idpdctmfactory,externalService,brokerIp,jmsConnectionFactory,redeliveryPolicy,jmsDestination,IDPjmsTemplate,jmsProducer,jmsListener,transactionManager,IDPJmsContainer]; root of factory hierarchy

[[/SecureClaim]] Initializing Spring root WebApplicationContext 09:23:45,260 INFO [ContextLoader] Root WebApplicationContext: initialization started 09:23:45,275 INFO [XmlWebApplicationContext] Refreshing org.springframework.web.context.support.XmlWebApplicationContext@1fbf66c: display name [Root WebApplicationContext]; startup date [Thu Jul 08 09:23:45 MDT 2010]; root of context hierarchy 09:23:45,275 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml] 09:23:45,291 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from URL [jar:file:/C:/jboss-4.2.3.GA/server/default/tmp/deploy/tmp608645178333044413IDP.ear-contents/IDPEJB.jar!/META-INF/applicationContext.xml] 09:23:45,306 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from URL [jar:file:/C:/jboss-4.2.3.GA/server/default/tmp/deploy/tmp7456914759893588436SecureClaim.ear-contents/SipsFacelet.jar!/META-INF/applicationContext.xml] 09:23:45,322 INFO [DefaultListableBeanFactory] Overriding bean definition for bean 'applicationContextProvider': replacing [Generic bean: class [org.idahosif.sips.common.spring.ApplicationContextProvider]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in ServletContext resource [/WEB-INF/applicationContext.xml]] with [Generic bean: class [org.idahosif.sips.common.spring.ApplicationContextProvider]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in URL [jar:file:/C:/jboss-4.2.3.GA/server/default/tmp/deploy/tmp7456914759893588436SecureClaim.ear-contents/SipsFacelet.jar!/META-INF/applicationContext.xml]] 09:23:45,322 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from URL [jar:file:/C:/jboss-4.2.3.GA/server/default/tmp/deploy/tmp7456914759893588436SecureClaim.ear-contents/SipsMessaging.jar!/META-INF/applicationContext.xml] 09:23:45,322 INFO [DefaultListableBeanFactory] Overriding bean definition for bean 'brokerIp': replacing [Generic bean: class [org.apache.activemq.ActiveMQConnectionFactory]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in URL [jar:file:/C:/jboss-4.2.3.GA/server/default/tmp/deploy/tmp608645178333044413IDP.ear-contents/IDPEJB.jar!/META-INF/applicationContext.xml]] with [Generic bean: class [org.apache.activemq.ActiveMQConnectionFactory]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in URL [jar:file:/C:/jboss-4.2.3.GA/server/default/tmp/deploy/tmp7456914759893588436SecureClaim.ear-contents/SipsMessaging.jar!/META-INF/applicationContext.xml]] 09:23:45,322 INFO [DefaultListableBeanFactory] Overriding bean definition for bean 'redeliveryPolicy': replacing [Generic bean: class [org.apache.activemq.RedeliveryPolicy]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in URL [jar:file:/C:/jboss-4.2.3.GA/server/default/tmp/deploy/tmp608645178333044413IDP.ear-contents/IDPEJB.jar!/META-INF/applicationContext.xml]] with [Generic bean: class [org.apache.activemq.RedeliveryPolicy]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in URL [jar:file:/C:/jboss-4.2.3.GA/server/default/tmp/deploy/tmp7456914759893588436SecureClaim.ear-contents/SipsMessaging.jar!/META-INF/applicationContext.xml]] 09:23:45,338 INFO [DefaultListableBeanFactory] Overriding bean definition for bean 'transactionManager': replacing [Generic bean: class [org.springframework.transaction.jta.JtaTransactionManager]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in URL [jar:file:/C:/jboss-4.2.3.GA/server/default/tmp/deploy/tmp608645178333044413IDP.ear-contents/IDPEJB.jar!/META-INF/applicationContext.xml]] with [Generic bean: class [org.springframework.transaction.jta.JtaTransactionManager]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in URL [jar:file:/C:/jboss-4.2.3.GA/server/default/tmp/deploy/tmp7456914759893588436SecureClaim.ear-contents/SipsMessaging.jar!/META-INF/applicationContext.xml]] 09:23:45,338 INFO [XmlWebApplicationContext] Bean factory for application context [org.springframework.web.context.support.XmlWebApplicationContext@1fbf66c]: org.springframework.beans.factory.support.DefaultListableBeanFactory@1632823 09:23:45,494 INFO [DefaultListableBeanFactory] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1632823: defining beans [powersuiteServiceFactory,url,qname,powersuiteService,documentumServiceFactory,documentumRepository,applicationContextProvider,brokerIp,jmsConnectionFactory,redeliveryPolicy,jmsDestination,IDPjmsTemplate,jmsProducer,jmsListener,transactionManager,IDPJmsContainer,externalServiceFactory,configProperties,externalServiceForIndex,appExternalVarForCAP,processVariables,connectionFactory,destination,jmsTemplate,jmsSender,messageListener,jmsContainer]; root of factory hierarchy**

I struggling on this for couple of days but I haven't find solution. Please help me if anyone gone through this issue before.

A: 

But I realized while debugging, one application bean definitions overriding the other.

Not sure what you saw while debugging, but based on the logs you have provided, you have two separate BeanFactories:

  • DefaultListableBeanFactory@8478d0 which combines bean definitions from

    • /WEB-INF/applicationContext-idp.xml
    • IDPEJB.jar!/META-INF/applicationContext.xml
  • DefaultListableBeanFactory@1632823 which combines bean definitions from

    • /WEB-INF/applicationContext.xml
    • IDP.ear/IDPEJB.jar!/META-INF/applicationContext.xml
    • SecureClaim.ear/SipsFacelet.jar!/META-INF/applicationContext.xml

I assume you have two web apps (one in each ear) and they both setup application context.

Your problems seems to be connected to the second context:

  • ApplicationContextProvider (bean name applicationContextProvider) defined in both: SecureClaim.ear/SipsFacelet.jar!/META-INF/applicationContext.xml and /WEB-INF/applicationContext.xml
  • ActiveMQConnectionFactory (bean name brokerIp) defined in both: IDP.ear/IDPEJB.jar!/META-INF/applicationContext.xml and SecureClaim.ear/SipsMessaging.jar!/META-INF/applicationContext.xml
  • RedeliveryPolicy (bean name RedeliveryPolicy) defined in both: IDP.ear/IDPEJB.jar!/META-INF/applicationContext.xml and SecureClaim.ear/SipsMessaging.jar!/META-INF/applicationContext.xml
  • JtaTransactionManager (bean name transactionManager) defined in both:
  • RedeliveryPolicy (bean name RedeliveryPolicy) defined in both: IDP.ear/IDPEJB.jar!/META-INF/applicationContext.xml and SecureClaim.ear/SipsMessaging.jar!/META-INF/applicationContext.xml

You have to make sure you need to include all this applicationContext.xml files. If that is the case (which I really doubt, but still) you should give your beans different names.

To understand better what is going on, can you post your web.xml for both web apps here?

Georgy Bolyuba