我在 eclipse 的部署中收到以下异常,告诉我我有一个重复的组件。它只被定义为我能看到的一类。我尝试重命名它,以防它干扰 JBoss 中的现有组件(看到有人遇到这个问题),结果相同。这是我第一次使用@Interceptors(SpringBeanAutowiringInterceptor.class)。我是不是配置错了?我使用 Eclipse/Kepler 创建为 EJB 3.0 项目,然后配置/转换为 Maven 项目。我想知道这是否导致生成了两个相同的类,但是使用 linux find 命令告诉我只有一个 MdbDequeueFrom.class。如果我注释掉,该项目将在调试器中部署和执行:
// @Stateless
// @Interceptors(SpringBeanAutowiringInterceptor.class)
除了豆子没有被注入。
未注释掉时的例外情况:
Caused by: java.lang.IllegalArgumentException: JBAS011046: A component named
'MdbDequeueFrom' is already defined in this module
at
org.jboss.as.ee.component.EEModuleDescription.addComponent(EEModuleDescription.java:140)
我的 MDB 定义为:
@MessageDriven(
activationConfig = { @ActivationConfigProperty(
propertyName = "destinationType", propertyValue =
"javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination",
propertyValue = "java:jboss/activemq/queue/IN_FROM"),
@ActivationConfigProperty(propertyName="acknowledgeMode",
propertyValue="Auto-acknowledge")
})
@Stateless
@Interceptors(SpringBeanAutowiringInterceptor.class)
@ResourceAdapter("activemq-ra.rar")
public class MdbDequeueFrom implements MessageListener {
@Autowired
private ReferralService referralService;
public MdbDequeueFrom() {
}
服务定义为:
@Service("referralService")
@Transactional(readOnly = false)
public class ReferralServiceImpl implements ReferralService {
private static final Logger logger =
LoggerFactory.getLogger(ReferralServiceImpl.class);
@Autowired
private ReferralDao referralDao;
我的 beanRefContext.xml 是:
<?xml version="1.0" encoding="UTF-8"?>
<beans>
<bean class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg value="classpath*:applicationContext.xml" />
</bean>
</beans>
我的 application.context 有:
<context:component-scan base-package="com.MdbDequeue"/>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:/OracleDS"/>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingLocations">
<list>
<value>classpath*:hbm/Referral.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="javax.persistence.validation.mode">none</prop>
</props>
</property>
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource"
p:basenames="messages" />
<context:annotation-config />
</beans>
它被定义为一个 EJB 3.0 Maven 项目
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org /2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MyGroup</groupId>
<artifactId>MdbDequeuer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>ejb</packaging>
<name>MdbDequeuer</name>
任何帮助将不胜感激。