【发布时间】:2021-05-14 09:23:16
【问题描述】:
我正在尝试使用 ejb2 和 solace 资源适配器将 solace 与 web sphere liberty 20 版本集成。我在 ejb 中配置了侦听队列的 MDB bean。我能够在 MDB 上获取消息,但是在处理时我需要将响应发布回队列,并且此队列名称是动态的,基于来自上游系统的消息。所以我不能将发布者配置为容器中的无状态 bean。
现在我想使用在 server.xml 中为 MDB 配置的发布者代码中的连接工厂,使用 solace 资源适配器。
我尝试了以下方法。
在 server.xml 中:
<featureManager>
<feature>javaee-8.0</feature>
<feature>localConnector-1.0</feature>
<feature>jndi-1.0</feature>
<feature>wasJmsClient-2.0</feature>
<feature>wasJmsServer-1.0</feature>
<feature>wasJmsSecurity-1.0</feature>
<feature>mdb-3.2</feature>
<feature>servlet-4.0</feature>
<feature>ejb-3.2</feature>
<feature>ejbHome-3.2</feature>
<feature>adminCenter-1.0</feature>
<feature>jca-1.7</feature>
<feature>jms-2.0</feature>
<feature>webProfile-8.0</feature>
<resourceAdapter autoStart="true" id="solace" location="sol-jms-ra-10.10.0.rar">
<properties.solace ConnectionURL="URL" UserName="user1" Password="pwd" MessageVPN="TEST_VPN"/>
</resourceAdapter>
<jmsActivationSpec id="JNDI/LISTENER">
<properties.solace connectionFactoryJndiName="myCF" destination="queue" destinationType="javax.jms.Queue" />
</jmsActivationSpec >
<jmsConnectionFactory id="JNDI/J2C/CF" jndiName="JNDI/J2C/CF">
<properties.solace ConnectionFactoryJndiName="myCF"/>
</jmsConnectionFactory>
并且在我的发布者代码中,如下进行 jndi 查找。
Context ctx = new InitialContext();
connectionFactory = (QueueConnectionFactory) ctx.lookup("java:comp/env/JNDI/J2C/CF");
connection = connectionFactory.createQueueConnection();
但得到以下异常
javax.naming.NameNotFoundException: javax.naming.NameNotFoundException: java:comp/env/JNDI/J2C/CF
at com.ibm.ws.jndi.url.contexts.javacolon.internal.JavaURLContext.lookup(JavaURLContext.java:355)
at com.ibm.ws.jndi.url.contexts.javacolon.internal.JavaURLContext.lookup(JavaURLContext.java:370)
at org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:149)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
有人可以帮我吗?
【问题讨论】:
标签: jms websphere-liberty solace open-liberty