我们的项目是在EAR中使用MDB和WEB,需要共享应用程序上下文.
web.xml中
<context-param>
<param-name>locatorFactorySelector</param-name>
<!-- This file is in the root of the EJB JAR file -->
<param-value>classpath:/META-INF/beanRefContext.xml</param-value>
</context-param>
<context-param>
<param-name>parentContextKey</param-name>
<!-- This is a bean name in the above XML file -->
<param-value>ejb-context</param-value>
</context-param>
Run Code Online (Sandbox Code Playgroud)
beanRefContext.xml
<bean id="ejb-context"
class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg>
<list>
<value>classpath:/META-INF/applicationContext.xml</value>
</list>
</constructor-arg>
</bean>
Run Code Online (Sandbox Code Playgroud)
applicationContext.xml中
<context:annotation-config />
<context:component-scan base-package="com.aer.iheal" />
Run Code Online (Sandbox Code Playgroud)
如果我们尝试将locatorFactorySelector加载为classpath*:beanRefContext.xml
(在jar的meta-inf下可用)并读取上面xml中可用的parentContextKey('ejb-context')bean.
我们正在低于错误
Unable to return specified BeanFactory instance: factory key [ejb-context], from group with resource name [classpath*:beanRefContext.xml]; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'ejb-context' is …
Run Code Online (Sandbox Code Playgroud)