I am using following MDB to connect to WMQ:
@MessageDriven(name = "EventListener", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "ABC"),
@ActivationConfigProperty(propertyName = "hostName", propertyValue = "ABC"),
@ActivationConfigProperty(propertyName = "port", propertyValue = "ABC"),
@ActivationConfigProperty(propertyName = "channel", propertyValue = "ABC"),
@ActivationConfigProperty(propertyName = "queueManager", propertyValue = "ABC"),
@ActivationConfigProperty(propertyName = "sslCipherSuite", propertyValue = "ABC"),
@ActivationConfigProperty(propertyName = "transportType", propertyValue = "CLIENT") })
@ResourceAdapter(value = "wmq.jmsra.rar")
@TransactionManagement(value = TransactionManagementType.CONTAINER)
@TransactionAttribute(value = TransactionAttributeType.REQUIRED)
@Interceptors(SpringBeanAutowiringInterceptor.class)
public class EventListener implements MessageListener {}
Following spring beans are being autowired as part of the interceptor annotation used in the above MDB. event-app-config.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.abc" />
<context:annotation-config/>
<import resource="classpath:core-app-config.xml" /> //This is another package
</beans>
Following is the core-app-config.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache.xsd">
<import resource="classpath:database-config.xml" />
<import resource="classpath:spring-jms-config.xml" />
</beans>
Main xml beanRefContext.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:annotation-config/>
<context:spring-configured/>
<bean id="beanRefFactory" class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg value="classpath*:event-app-config.xml" />
</bean>
</beans>
I am autowiring certain bean instances from database & spring jms xmls in the MDB package but looks like all the beans inside these xmls are not created. Can you please understand what can be the issue. Does the autowire functionality of the MDB restricted to the spring xmls in the same package and any other imports being done inside parent spring bean xml is not created?
Example: EventListener
is in com.abc.xyz
package. I am autowiring instance of class A
from com.abc.core package in eventlistener class. Class A
is @Service
and that in turn has autowired dependency say Class B
which in com.abc.packB
. So when the instance of class A
is created I get an exception saying that no Class B
definition is found.