Reputation: 1
We have a java web application which connects to queues(IBM MQ). It works fine in IBM WAS 8.5 where we have configured queue connection factories and queues in the WAS 8.5 console. The application looks up the queue connection factory and queue thru JNDI. But we have to move to WebSphere Liberty and the same application does not work when deployed in WebSphere Liberty.
We have issues in the JNDI lookup itself. Below is the code we are using.
Properties properties = new Properties();
properties.put("java.naming.provider.url", providerURL);
properties.put("java.naming.factory.initial", "com.ibm.websphere.naming.WsnInitialContextFactory");
InitialContext initialContext = new InitialContext(properties);
connFactory = (QueueConnectionFactory) initialContext.lookup("jms/queueconnfactory");
During lookup we get the exception Name jms not found in context "serverlocal:CELLROOT/SERVERROOT".
Below is the config in the Liberty server xml
<jmsQueueConnectionFactory id="XXXXXXXXXXXXXXXXXXXXX" jndiName="jms/queueconnfactory">
<connectionManager maxPoolSize="20" connectionTimeout="0"/>
<properties.wmqJms queueManager="uwdev" transportType="CLIENT" sslCipherSuite="TLS_RSA_WITH_AES_256_CBC_SHA256" connectionNameList="xxxxxxxxxx" channel="xxxxxxxxx"/>
</jmsQueueConnectionFactory>
Below are the features added
<featureManager>
<feature>adminCenter-1.0</feature>
<feature>batchManagement-1.0</feature>
<feature>collectiveController-1.0</feature>
<feature>appSecurity-2.0</feature>
<feature>restConnector-2.0</feature>
<feature>jdbc-4.3</feature>
<feature>mpOpenApi-3.0</feature>
<feature>servlet-3.1</feature>
<feature>jsp-2.3</feature>
<feature>mpConfig-1.3</feature>
<feature>wmqJmsClient-2.0</feature>
<feature>jndi-1.0</feature>
<feature>jaxb-2.2</feature>
<feature>jmsMdb-3.2</feature>
<feature>transportSecurity-1.0</feature>
<feature>ssl-1.0</feature>
</featureManager>
We are trying to connect to the queue from Liberty using JNDI lookup
Upvotes: 0
Views: 471
Reputation: 18050
A few things to check:
server.xml
which configures resource adapter<resourceAdapter id="wmqjmsra" location="path_to/wmq.jakarta.jmsra.rar" />
with correct adapter for your mq version. Check this for details: https://www.ibm.com/docs/en/ibm-mq/9.2?topic=adapter-liberty-mq-resource
message.log
during the startup if everything is initialized correctlyInstead of lookup
if you are running in a Java EE component you could use injection like this:
@Resource(lookup = "jms/myqueue")
private Queue queue;
@Resource(lookup = "jms/queueconnfactory")
private QueueConnectionFactory queueCF;
Otherwise make sure you are using just default constructor like this:
InitialContext initialContext = new InitialContext();
QueueConnectionFactory connFactory = (QueueConnectionFactory) initialContext.lookup("jms/queueconnfactory");
Upvotes: 0