我正在尝试将消息驱动的bean添加到我现有的Java EE应用程序中。我正在修改部署描述符ejb-jar.xml。我的ejb-jar.xml看起来像这样。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD EnterpriseJavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="ejb-jar_1" version="2.1" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
...
<enterprise-beans>
...
<session>
...
<service-ref> ... <service-ref>
</session>
<message-driven>
<ejb-name>Services</ejb-name>
<ejb-class>com.pega.pegarules.internal.etier.mdb.PRJMSListenerBoot</ejb-class>
<transaction-type>Container</transaction-type>
<message-driven-destination id="MessageDrivenDestination_Services">
<destination-type>javax.jms.Queue</destination-type>
</message-driven-destination>
</message-driven>
...
</ejb-jar>
当我尝试在WebSphere上部署我的应用程序时,它会给我以下错误。
[10/16/12 17:20:05:671 CDT] 00000024 webapp I com.ibm.ws.webcontainer.webapp.WebApp log SRVE0292I: Servlet Message - [isclite#isclite.war]:.action: ApplicationDeploymentDetailForm was null.Creating new form bean and storing in session
[10/16/12 17:20:19:524 CDT] 00000046 wtp W Parse exception for [ public ID [ null ] and system ID [ null ] ] [ java.lang.IllegalStateException: Parent Translator (EnterpriseBeansTranslator(entity|session|message-driven,1696032023)) did not find a Child Translator for "message-driven-destination". ]
在使用XML文件播放了几天后,我发现,当我删除上面的EJB-JAR元素中给出的名称空间时,消息驱动的用途被正确翻译,但是元素会失败,而不是同一子女翻译器。发现错误。
所以我相信这是一个命名空间冲突问题。如果有人可以帮助我解决这个问题。
预先感谢。
我发现了问题。ejb-jar-2.1.xsd从消息驱动类型中弃用了消息驱动的用途元素。消息驱动的目的地是EJB-JAR_2.0 Spec的一部分。
EJB 2.0中的消息驱动bean元素的示例:
<message-driven id="Mdb20">
<ejb-name>Mdb</ejb-name>
<ejb-class>ejbs.MdbBean</ejb-class>
<transaction-type>Bean</transaction-type>
<message-selector>mdbMessage</message-selector>
<acknowledge-mode>Auto-acknowledge</acknowledge-mode>
<message-driven-destination>
<destination-type>javax.jms.Topic</destination-type>
<subscription-durability>Durable</subscription-durability>
</message-driven-destination>
</message-driven>
EJB 2.1中的消息驱动bean元素的示例:
<message-driven id="Mdb21">
<ejb-name>Foo/ejb-name>
<ejb-class>ejbs.FooBean</ejb-class>
<messaging-type>javax.jms.MessageListener</messaging-type>
<transaction-type>Bean/transaction-type>
<message-destination-type>javax.jms.Topic</message-destination-type>
<activation-config>
<activation-config-property>
<activation-config-property-name>destinationType</activation-config-property-name>
<activation-config-property-value>javax.jms.Topic</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>subscriptionDurability</activation-config-property-name>
<activation-config-property-value>Durable</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>acknowledgeMode</activation-config-property-name>
<activation-config-property-value>AutoAcknowledge</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>messageSelector</activation-config-property-name>
<activation-config-property-value>fooSelector</activation-config-property-value>
</activation-config-property>
</activation-config>
</message-driven>