Weblogic 注入失败时 MDB 的 SpringBeanAutowiringInterceptor

SpringBeanAutowiringInterceptor for MDB on Weblogic injection failure

我有一个使用 EJB 和 Spring4 的 JavaEE 6 应用程序,它带有一个接收单个 bean 注入的简单 MDB,但是,每次我向这个 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 参考:

<?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>

谢谢。

根据 Spring 的问题:https://jira.spring.io/browse/SPR-14187

,这是 Weblogic 服务器的类加载器问题