1

我正在尝试将消息驱动 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 被正确翻译,但元素失败,并出现相同的 Child translate not found 错误。

所以我相信这是一个命名空间冲突问题。如果有人可以帮助我解决这个问题,我很感激。

提前致谢。

4

1 回答 1

2

我弄清楚了这个问题。ejb-jar-2.1.xsd 已弃用消息驱动类型中的消息驱动目标元素。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>
于 2012-10-27T14:25:35.790 回答