用于MDB的SpringBeanAutowiringInterceptor对Weblogic注入失败

时间:2016-03-30 21:30:10

标签: spring java-ee message-driven-bean

我有一个使用EJB和Spring 4的JavaEE 6应用程序,其中一个简单的MDB接收单个bean注入,但是,每次我向此MDB发送消息时,都会显示以下日志:

com.oracle.pitchfork.interfaces.LifecycleCallbackException: Failure to invoke public void org.springframework.ejb.interceptor.SpringBeanAutowiringInterceptor.autowireBean(javax.interceptor.InvocationContext) on bean class class  app.module.mdb.impl.SpringBeanAutowiringInterceptor2_curj4r_Impl with args: [LifecycleEventCallbackInvocationContext(1495657191)]

..

Caused By: org.springframework.beans.factory.BeanCreationException: Injection of autowired dependencies failed for class [class app.module.mdb.impl.TestMDB]; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private app.module.bizo.impl.TestBOImpl  app.module.mdb.impl.TestMDB.bizo; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [app.module.bizo.impl.TestBOImpl] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

我想知道我做错了什么,因为我已经正确配置了所有内容。

MDB:

@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
        @ActivationConfigProperty(propertyName = "connectionFactoryJndiName") })
@TransactionManagement(TransactionManagementType.CONTAINER)
@Interceptors(SpringBeanAutowiringInterceptor2.class)
public class TestMDB implements MessageListener {

    @Autowired
    private TestBO bizo;

    @Logging
    @Override
    @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
    public void onMessage(final Message message) {
        try {

            this.bizo.process(message);
        } catch (final Exception e) {
            throw new RuntimeException(e.getCause());
        }

    }

}

BO:

@Component
public class TestBOImpl implements TestBO, Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    @Override
    public void process(Message message) throws BusinessException {
        System.out.println("Im here!");

    }

}

配置:

<?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:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
    xmlns:task="http://www.springframework.org/schema/task"
    xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
    http://www.springframework.org/schema/tx      http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
    http://www.springframework.org/schema/util    http://www.springframework.org/schema/util/spring-util-4.0.xsd
    http://www.springframework.org/schema/task    http://www.springframework.org/schema/task/spring-task-4.0.xsd">


    <context:annotation-config />
    <context:component-scan base-package="app.module" />

</beans>

XML Ref:

<?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-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">

    <bean id="IDContext" class="org.springframework.context.support.ClassPathXmlApplicationContext">
        <constructor-arg value="/META-INF/app-config.xml" />
    </bean>
</beans>

感谢。

1 个答案:

答案 0 :(得分:0)

根据Spring的问题,这是来自Weblogic服务器的类加载器问题:https://jira.spring.io/browse/SPR-14187