WebSphere Liberty:中间上下文不存在:jms/<;连接工厂jndi>;

WebSphere Liberty:中间上下文不存在:jms/<;连接工厂jndi>;,jms,jndi,websphere-liberty,Jms,Jndi,Websphere Liberty,我在尝试通过Liberty 20.0.0.1上的jndi查找向JMS队列发送xml消息时遇到问题 My server.xml是: <?xml version="1.0" encoding="UTF-8"?> <server description="Default server"> <featureManager> <feature>el-3.0</featu

我在尝试通过Liberty 20.0.0.1上的jndi查找向JMS队列发送xml消息时遇到问题

My server.xml是:

<?xml version="1.0" encoding="UTF-8"?>
<server description="Default server">
    <featureManager>
        <feature>el-3.0</feature>
        <feature>localConnector-1.0</feature>
        <feature>monitor-1.0</feature>
        <feature>restConnector-2.0</feature>
        <feature>jacc-1.5</feature>
        <feature>servlet-4.0</feature>
        <feature>jndi-1.0</feature>
        <feature>concurrent-1.0</feature>
        <feature>requestTiming-1.0</feature>
        <feature>ssl-1.0</feature>
        <feature>jdbc-4.0</feature>
        <feature>cdi-2.0</feature>
        <feature>jms-2.0</feature>
        <feature>jaxrs-2.1</feature>
        <feature>ejbLite-3.2</feature>
    </featureManager>

    <httpEndpoint id="defaultHttpEndpoint"
              host="*"
              httpPort="9080"
              httpsPort="9443" />

    <!-- Automatically expand WAR files and EAR files-->
    <applicationManager autoExpand="true"/>
    <applicationMonitor updateTrigger="mbean"/>

    <messagingEngine>
        <queue id="jmsQueue" forceReliability="ReliablePersistent" maxMessageDepth="5000"></queue>
    </messagingEngine>

    <jmsQueueConnectionFactory jndiName="jms/JMS_CF" connectionManagerRef="ConMgr">
        <properties.wasJms
            nonPersistentMapping="ExpressNonPersistent"
            persistentMapping="ReliablePersistent"/>
    </jmsQueueConnectionFactory>

    <connectionManager id="ConMgr" maxPoolSize="10"/>

    <jmsQueue id="jms_StockQueue" jndiName="jms/STOCK_JMS_QUEUE">
        <properties.wasJms queueName="stockQueue"
            deliveryMode="Application"
            timeToLive="500000"
            priority="1"
            readAhead="AsConnection" />
    </jmsQueue>

    <jmsActivationSpec id="core_indexing/jms-mdb/StockMDB">
        <properties.wasJms destinationRef="jms_StockQueue" />
    </jmsActivationSpec>
</server>
但是,当我针对容器中的代码运行测试时,我得到:

Intermediate context does not exist: jms/JMS_CF
javax.naming.NameNotFoundException: Intermediate context does not exist: jms/JMS_CF
at com.ibm.ws.jndi.internal.ContextNode.getTargetNode(ContextNode.java:125) ~[?:?]
at com.ibm.ws.jndi.internal.ContextNode.lookup(ContextNode.java:211) ~[?:?]
at com.ibm.ws.jndi.internal.WSContext.lookup(WSContext.java:306) ~[?:?]
at com.ibm.ws.jndi.WSContextBase.lookup(WSContextBase.java:61) ~[?:?]
at org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:161) ~[?:?]
at javax.naming.InitialContext.lookup(InitialContext.java:428) ~[?:1.8.0]
如果我更改Java代码,以便使用@Resource完成连接工厂查找,即

@Resource(lookup = "jms/JMS_CF")
private QueueConnectionFactory queueConnectionFactory;
错误是:

[ERROR   ] SRVE0315E: An exception occurred: java.lang.Throwable: 
javax.ejb.EJBException: CWNEN0030E: The server was unable to obtain an object 
instance for the 
java:comp/env/com.xyz.www.stock.api.ws.StockWS/queueConnectionFactory 
reference.  The exception message was: CWNEN1003E: The server was unable to 
find the jms/JMS_CF binding with the javax.jms.QueueConnectionFactory type 
for the java:comp/env/com.xyz.www.stock.api.ws.StockWS/queueConnectionFactory
reference.
将jms-2.0替换为wasJmsServer-1.0和 wasJmsClient-2.0消除了JNDI查找错误,但MDB不会激活。

取代

<feature>jms-2.0</feature>
jms-2.0

wasJmsServer-1.0
wasJmsClient-2.0
mdb-3.2

我也遇到了这个错误,尽管
的JNDI名称与应用程序要查找的名称完全相同

问题是连接工厂被配置为使用IBM WebSphere MQ,这在Open Liberty中不可用。在执行步骤之后,错误消失了

<feature>jms-2.0</feature>
<feature>wasJmsServer-1.0</feature>
<feature>wasJmsClient-2.0</feature>
<feature>mdb-3.2</feature>