0
我已经经历了大部分资源,并试图通过以下机制将Spring Bean获取到我的MDB。SpringBeanAutowiringInterceptor不向消息驱动Bean注入Spring Bean:空指针异常
@MessageDriven(name = "FileMDB")
@Interceptors(SpringBeanAutowiringInterceptor.class)
public class FileMessageBean implements MessageListener {
@Autowired
private IContextLoader contextLoader;
@Override
public final void onMessage(final Message message) {
}
}
我的beanRefContext.xml位于JAR文件的类路径中,它是WAR文件的依赖关系。
<?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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="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">
<bean
class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg value="classpath:channel-integration-context.xml" />
</bean>
</beans>
通道集成-context.xml的
<?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:mvc="http://www.springframework.org/schema/mvc"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
<!-- Activates various annotations to be detected in bean classes: Spring's
@Required and @Autowired, as well as JSR 250's @Resource. -->
<!-- <context:annotation-config /> -->
<!-- AOP Annotation -->
<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
<!-- File Adapter -->
<import resource="classpath:channel-dao-beans.xml" />
<!-- JMS Beans -->
<import resource="classpath:jms-beans.xml" />
<!-- Data JNDI Beans -->
<import resource="classpath:datasource-jndi-beans.xml" />
<context:component-scan base-package="com.fdc.channelintegration" />
<bean id="contextLoader" class="com.fdc.channelintegration.util.SpringContextLoader">
</bean>
</beans>
我使用Websphere 8.5和我的MDB正确触发。仍然contextLoader没有注入到MDB,我得到一个NullPointerException。
请帮我一把。
谢谢你,小问题。为什么要移除SpringBeanAutowiringInterceptor?它假设将spring bean注入EJB的权利?有点困惑。 – 2014-12-11 06:44:06