I have two EARs that contain unique WAR and EJB JAR files.
Each EAR contains a beanRefContext.xml file that I have wired up to multiple applicationContext files to use Autowiring in my EJB implementation classes.
My EARs are configured to be isolated in the JBoss EAR deployer.
Each of my EJBs is configured to use the @Interceptors(SpringBeanAutowiringInterceptor.class)
EAR 1
--- WAR1
--- EJB1 JAR
EAR 2
--- WAR2
--- EJB2 JAR
My issues is when I deploy both of these EARs in the same JBoss instance and attempt to have EJB1 call EJB2 via a remote EJB call I receive the following exception:
{code}Caused by: java.lang.RuntimeException: org.springframework.beans.factory.access.BootstrapException: Unable to return specified BeanFactory instance: factory key [null], from group with resource name [classpath*:beanRefContext.xml]; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [org.springframework.beans.factory.BeanFactory] is defined: expected single bean but found 2{code}
This exception is thrown from EJB1 when it attemps to make a remote ejb call to EJB2. To verify that this is an issue with Spring Integration I removed the @Interceptors(SpringBeanAutowiringInterceptor.class) from EJB2 and returned some dummy data and it worked fine. It seems this issue revolves around the SpringBeanAutowiringInterceptor.class.
Any help here resolving this issue would be much appreciated!
Here are the beanRefContext.xml files which are include in the root of the EAR files.
EAR1
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<bean id="ear1-context" class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg>
<list>
<value>ejb1-applicationContext.xml</value>
<value>dao1-applicationContext.xml</value>
</list>
</constructor-arg>
</bean>
</beans>
EAR2
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<bean id="ear2-context">
<constructor-arg>
<list>
<value>ejb2-applicationContext.xml</value>
<value>dao2-applicationContext.xml</value>
</list>
</constructor-arg>
</bean>
</beans>
-Kyle