What I am trying to accomplish is sharing Spring context between one jar and two war's. All of them are packed in ear.
Here is beanRefContext.xml located in the jar:
<bean id="mainApplicationContext"
class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg>
<list>
<value>/META-INF/spring/main-applicationContext.xml</value>
</list>
</constructor-arg>
</bean>
main-applicationContext.xml contains beans I would like to share between two war's.
Here is the web.xml in one war:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listenerclass>
</listener>
<context-param>
<param-name>locatorFactorySelector</param-name>
<param-value>/META-INF/spring/beanRefContext.xml</param-value>
</context-param>
<context-param>
<param-name>parentContextKey</param-name>
<param-value>mainApplicationContext</param-value>
</context-param>
And similar in the other war.
From Jboss logs I can clearly see that all beans from main-applicationContext.xml are instantiated:
[org.springframework.beans.factory.xml.XmlBeanDefinitionReader] Loaded 265 bean definitions from location pattern [/META-INF/spring/main-applicationContext.xml]
Moreover in one of the war's I have local spring context containing beans local to that particular war. Those beans are instantiated properly as well:
[org.springframework.beans.factory.xml.XmlBeanDefinitionReader] Loaded 55 bean definitions from location pattern [/WEB-INF/applicationContext.xml]
The beans are injected correctly into beans located in jar. However there are not injected into Struts actions and beans located in the mentioned earlier beans local for the web application (defined in /WEB-INF/applicationContext.xml).
What I would expect that beanRefContext.xml is parent context for local web context.
Where am I wrong?
Thank you in advance for any help.