gpt4 book ai didi

wildfly-8 - 混合注释和部署描述符时为 "Destination is mandatory"

转载 作者:行者123 更新时间:2023-12-03 06:53:33 32 4
gpt4 key购买 nike

我正在尝试在 wildfly 8.2.0-Final 上定义带有注释和部署描述符的消息驱动 bean。我想用注释声明配置的静态部分,用 xml 部署描述符声明变量部分。部署以下 mdb 时,出现异常。

这是 .failed-File 的内容:

{"JBAS014671: Failed services" => {"jboss.deployment.unit.\"MdbWithAnnotationsAndDescritors.jar\".component.NewMessageBean.START" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"MdbWithAnnotationsAndDescritors.jar\".component.NewMessageBean.START: java.lang.RuntimeException: javax.resource.spi.InvalidPropertyException: Destination is mandatory Caused by: java.lang.RuntimeException: javax.resource.spi.InvalidPropertyException: Destination is mandatory Caused by: javax.resource.spi.InvalidPropertyException: Destination is mandatory"}}

mdb 是

package test;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.JMSDestinationDefinition;
import javax.jms.Message;
import javax.jms.MessageListener;
@JMSDestinationDefinition(name = "testQueue", interfaceName = "javax.jms.Queue", resourceAdapter = "jmsra", destinationName = "testQueue")
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
})
public class NewMessageBean implements MessageListener {
public NewMessageBean() {
}
@Override
public void onMessage(Message message) {
}
}

和 jboss.xml 部署描述符:

<jboss xsi:schemaLocation="http://java.sun.com/xml/ns/javaee                             http://www.jboss.org/j2ee/schema/jboss_5_0.xsd" version="3.0">
<security-domain>tutorial-default</security-domain>
<enterprise-beans>
<message-driven>
<ejb-name>testQueue</ejb-name>
<destination-jndi-name>testQueue</destination-jndi-name>
</message-driven>
</enterprise-beans>
</jboss>

ejb-jar.xml 为空:

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://xmlns.jcp.org/xml/ns/javaee"
version="3.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/ejb-jar_3_2.xsd">

</ejb-jar>

最佳答案

明白了,我将目标 ActivationConfigProperty 添加到 mdb 类中以消除异常:

package test;

import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.JMSDestinationDefinition;
import javax.jms.Message;
import javax.jms.MessageListener;

/**
*
* @author rainer
*/
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "willBeOverwrittenInDeploymentDescriptor")
})
public class NewMessageBean implements MessageListener {

public NewMessageBean() {
}

@Override
public void onMessage(Message message) {
}

}

我删除了 JMSDestinationDefinition,因为不需要它,我使用管理控制台创建了队列。为了覆盖目标 jndi 名称,我创建了以下 ejb-jar.xml

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd">
<enterprise-beans>
<message-driven>
<ejb-name>NewMessageBean</ejb-name>
<ejb-class>test.NewMessageBean</ejb-class>

<activation-config>
<activation-config-property>
<activation-config-property-name>destination</activation-config-property-name>
<activation-config-property-value>/jms/testClientQueue</activation-config-property-value>
</activation-config-property>
</activation-config>
</message-driven>
</enterprise-beans>
</ejb-jar>

现在 mdb 已部署并监听队列 jms/testClientQueue

关于wildfly-8 - 混合注释和部署描述符时为 "Destination is mandatory",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28029735/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com