所以我正在努力迁移到JBoss7 ......知道我遇到了一堆与我的XML相关的问题(正如预期的那样)。首先是
<acknowledge-mode>Auto-acknowledge</acknowledge-mode>
已从此thread
解决现在我得到了:
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[39,10]
Message: Unexpected element 'message-driven-destination' encountered
at org.jboss.metadat a.parser.util.MetaDataElementParser.unexpectedElement(MetaDataElementParser.java:109)
这是因为我的xml包含:
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
<subscription-durability>Durable</subscription-durability>
</message-driven-destination>
但我无法弄清楚应该如何正确设置目的地类型。
我的完整ejb-jar.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar >
<description><![CDATA[Message Driven Bean for processing subscription.]]></description>
<display-name>EJB Bean</display-name>
<enterprise-beans>
<!-- Message Driven Beans -->
<message-driven >
<description><![CDATA[Bean for processing subscription.]]></description>
<display-name>EJB Subscription Bean</display-name>
<ejb-name>EJBSubscriptionBean</ejb-name>
<ejb-class>com.package.bean.EJBSubscriptionBean</ejb-class>
<transaction-type>Container</transaction-type>
<!-- To work with JBoss7 -->
<!-- <acknowledge-mode>Auto-acknowledge</acknowledge-mode> -->
<activation-config>
<activation-config-property>
<activation-config-property-name>acknowledgeMode</activation-config-property-name>
<activation-config-property-value>Auto-acknowledge</activation-config-property-value>
</activation-config-property>
</activation-config>
<!-- -->
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
<subscription-durability>Durable</subscription-durability>
</message-driven-destination>
</message-driven>
<message-driven >
<description><![CDATA[Bean for processing refunds.]]></description>
<display-name>E Refund Bean</display-name>
<ejb-name>EJBRefundBean</ejb-name>
<ejb-class>com.package.bean.EJBRefundBean</ejb-class>
<transaction-type>Container</transaction-type>
<!-- To work with JBoss7 -->
<!-- <acknowledge-mode>Auto-acknowledge</acknowledge-mode> -->
<activation-config>
<activation-config-property>
<activation-config-property-name>acknowledgeMode</activation-config-property-name>
<activation-config-property-value>Auto-acknowledge</activation-config-property-value>
</activation-config-property>
</activation-config>
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
<subscription-durability>Durable</subscription-durability>
</message-driven-destination>
</enterprise-beans>
</ejb-jar>
提前感谢您的帮助。
答案 0 :(得分:3)
我已将ejb-jar.xml完全更改为:
<!--?xml version="1.0"?-->
<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_0.xsd">
<interceptors>
<interceptor>
<interceptor-class>com.package.bean.EJBSubscriptionBean</interceptor-class>
</interceptor>
<interceptor>
<interceptor-class>com.package.bean.EJBRefundBean</interceptor-class>
</interceptor>
</interceptors>
<assembly-descriptor>
<interceptor-binding>
<ejb-name>EJBSubscriptionBean</ejb-name>
<interceptor-class>com.package.bean.EJBSubscriptionBean</interceptor-class>
</interceptor-binding>
<interceptor-binding>
<ejb-name>EJBRefundBean</ejb-name>
<interceptor-class>com.package.bean.EJBRefundBean</interceptor-class>
</interceptor-binding>
</assembly-descriptor>
</ejb-jar>
并通过Beans本身的Annotations添加设置:
//JBoss 7 / JDK 6 / EJB3 Annotations
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
// @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/TEST_QUEUE"),
@ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "Durable") })
答案 1 :(得分:3)
'message-driven-destination'。 将通过
替换标记来解决此问题<message-destination-type>javax.jms.Queue</message-destination-type>
<activation-config>
<activation-config-property>
<activation-config-property-name>destinationType</activation-config-property-name>
<activation-config-property-value>javax.jms.Queue</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>destination</activation-config-property-name>
<activation-config-property-value>java:/queue/CacheQueue</activation-config-property-value>
</activation-config-property>
</activation-config>