在同一个ejb-jar.xml中使用<message-driven>和<service-ref> </service-ref> </message-driven>

时间:2012-10-25 19:44:04

标签: xml java-ee xml-namespaces message-driven-bean ejb-jar.xml

我正在尝试将消息驱动的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元素中给出的命名空间时,message-driven-destination被正确翻译但是元素错误与同一个子翻译器没有发现错误。

所以我认为这是名称空间冲突问题。如果有人可以帮我解决这个问题,我会很乐意。

提前致谢。

1 个答案:

答案 0 :(得分:1)

我想出了这个问题。 ejb-jar-2.1.xsd不推荐使用消息驱动类型的message-driven-destination元素。 message-driven-destination是ejb-jar_2.0规范的一部分。这是从2.0到2.1的转换:

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>