You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WebSphere迁移OpenLiberty:EJB 3 MDB的ibm-ejb-jar-bnd.xmi适配问题

WebSphere 8.x EAR迁移OpenLiberty的EJB绑定适配方案

问题背景

将包含2个WAR包的EAR从WebSphere 8.x迁移到OpenLiberty时,部署报错,提示ibm-ejb-jar-bnd.xmi中的listenerInputPortName属性是意外元素。直接删除该属性后可部署,但担心影响MDB的JMS队列连接功能。

错误日志

[ERROR   ] CWWKZ0002E: An exception occurred while starting the application NAMEOFEAR-1.0.0. The exception message was: com.ibm.ws.container.service.metadata.MetaDataException: com.ibm.wsspi.adaptable.module.UnableToAdaptException: com.ibm.ejs.container.EJBConfigurationException: com.ibm.wsspi.adaptable.module.UnableToAdaptException: com.ibm.ws.javaee.ddmodel.DDParser$ParseException: CWWKC2256E: Unexpected attribute listenerInputPortName encountered parsing element ejbBindings in the NAMEOFEAR-1.0.0.ear : NAMEOFJAR-1.0.0.jar : META-INF/ibm-ejb-jar-bnd.xmi deployment descriptor on line 4.

现有配置

1. ibm-ejb-jar-bnd.xmi

<?xml version="1.0" encoding="UTF-8"?>
<ejbbnd:EJBJarBinding xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ejb="ejb.xmi" xmlns:ejbbnd="ejbbnd.xmi" xmi:id="EJBJarBinding_1">
  <ejbJar href="META-INF/ejb-jar.xml#ejb-jar_ID"/>
  <ejbBindings xmi:type="ejbbnd:MessageDrivenBeanBinding" xmi:id="MessageDrivenBeanBinding_1" listenerInputPortName="SMTPMessageListenerPort">
    <enterpriseBean xmi:type="ejb:MessageDriven" href="META-INF/ejb-jar.xml#MessageDriven_1"/>
    <resRefBindings xmi:id="ResourceRefBinding_1" jndiName="mail/SMTPMailSession">
  </ejbBindings>
</ejbbnd:EJBJarBinding>

2. ejb-jar.xml

<ejb-jar ...>
    <display-name>ejb</display-name>
    <enterprise-beans>
        <message-driven id="MessageDriven_1">
            <ejb-name>SMTPSender</ejb-name>
            <ejb-class>com.smtp.SMTPSendBean</ejb-class>
            <transaction-type>Container</transaction-type>
            <message-destination-type>javax.jms.Queue</message-destination-type>
            <activation-config>
              ...
            </activation-config>
            <resource-ref id="ResourceRef_1">
              ...
            </resource-ref>
        </message-driven>
    </enterprise-beans>
</ejb-jar>

3. JMS-resources.xml(config-dropins)

<?xml version="1.0" encoding="UTF-8"?>
<server>
 ...

    <jmsQueueConnectionFactory jndiName="jms/CompanySMTPMessageConnectionFactory">
        <properties.mqJMS
                ...
                transportType="CLIENT"/>
    </jmsQueueConnectionFactory>

    <jmsQueue jndiName="jms/SMTPMessageQueue">
        <properties.mqJMS baseQueueName="Q2"/>
    </jmsQueue>
</server>

适配方案

listenerInputPortName是WebSphere 8.x专有配置,对应旧版Listener Port机制,OpenLiberty遵循EJB 3.1规范,改用标准JMS激活规范(Activation Spec)替代Listener Port,需按以下步骤修改:

步骤1:清理旧版绑定文件

删除ibm-ejb-jar-bnd.xmi中的listenerInputPortName属性,保留资源引用绑定:

<?xml version="1.0" encoding="UTF-8"?>
<ejbbnd:EJBJarBinding xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ejb="ejb.xmi" xmlns:ejbbnd="ejbbnd.xmi" xmi:id="EJBJarBinding_1">
  <ejbJar href="META-INF/ejb-jar.xml#ejb-jar_ID"/>
  <ejbBindings xmi:type="ejbbnd:MessageDrivenBeanBinding" xmi:id="MessageDrivenBeanBinding_1">
    <enterpriseBean xmi:type="ejb:MessageDriven" href="META-INF/ejb-jar.xml#MessageDriven_1"/>
    <resRefBindings xmi:id="ResourceRefBinding_1" jndiName="mail/SMTPMailSession">
  </ejbBindings>
</ejbbnd:EJBJarBinding>

步骤2:配置OpenLiberty的JMS激活规范

在JMS-resources.xml中添加激活规范,关联已有的JMS队列和连接工厂:

<jmsActivationSpec jndiName="jms/SMTPSenderActivationSpec">
    <properties.mqJMS
        destinationRef="jms/SMTPMessageQueue"
        connectionFactoryRef="jms/CompanySMTPMessageConnectionFactory"
        transportType="CLIENT"
        <!-- 可添加原Listener Port的其他配置,如maxConcurrency、acknowledgeMode等 -->
    />
</jmsActivationSpec>

步骤3:关联MDB到激活规范

有两种方式可选:

方式A:修改ejb-jar.xml配置激活参数

更新message-driven节点的activation-config,指定JMS资源的JNDI名称:

<message-driven id="MessageDriven_1">
    <ejb-name>SMTPSender</ejb-name>
    <ejb-class>com.smtp.SMTPSendBean</ejb-class>
    <transaction-type>Container</transaction-type>
    <message-destination-type>javax.jms.Queue</message-destination-type>
    <activation-config>
        <activation-config-property>
            <activation-config-property-name>destinationJndiName</activation-config-property-name>
            <activation-config-property-value>jms/SMTPMessageQueue</activation-config-property-value>
        </activation-config-property>
        <activation-config-property>
            <activation-config-property-name>connectionFactoryJndiName</activation-config-property-name>
            <activation-config-property-value>jms/CompanySMTPMessageConnectionFactory</activation-config-property-value>
        </activation-config-property>
        <!-- 其他JMS配置参数,如acknowledgeMode、maxMessagesPerSessions等 -->
    </activation-config>
    <resource-ref id="ResourceRef_1">
        ...
    </resource-ref>
</message-driven>

方式B:使用标准绑定文件替代XMI

创建ibm-ejb-jar-bnd.xml(放置在EJB JAR的META-INF目录),绑定MDB到激活规范:

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar-bnd xmlns="http://websphere.ibm.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-ejb-jar-bnd_1_0.xsd"
    version="1.0">
    <message-driven name="SMTPSender">
        <jms-activation-spec binding-name="jms/SMTPSenderActivationSpec"/>
        <resource-ref name="mail/SMTPMailSession" binding-name="mail/SMTPMailSession"/>
    </message-driven>
</ejb-jar-bnd>

说明

直接删除listenerInputPortName后部署成功,但MDB无法自动连接JMS队列,必须通过上述步骤配置激活规范,才能保证MDB正常接收队列消息。该方案完全遵循EJB 3.1规范,适配OpenLiberty的运行机制。

内容的提问来源于stack exchange,提问作者Deery

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 09:56:01