MQJMS2005 exception failed to create MQQueueManage

2019-08-01 20:30发布

问题:

In my GetJMSMessage, I used this:

MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
cf.setPort(port);
cf.setHostName(host);
cf.setChannel(channel);
cf.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
cf.setQueueManager(queuemanager);
conn = (MQQueueConnection)cf.createQueueConnection();

This works when I run my class as a standalone app. However, when I deployed my project in Weblogic 10, it gave a JMSException error. IBM MQ is deployed remotely and I have no access to it.

The error stacktrace is javax.jms.JMSException:

MQJMS2005: failed to create MQQueueManager for 'hostname:queuemanager'
at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:644) 
at com.ibm.mq.jms.MQConnection.createQM(MQConnection.java:2567) 
at com.ibm.mq.jms.MQConnection.createQMNonXA(MQConnection.java:1912) 
at com.ibm.mq.jms.MQQueueConnection.<init>(MQQueueConnection.java:161) 
at com.ibm.mq.jms.MQQueueConnectionFactory.createQueueConnection(MQQueueConnectionFactory.java:202)
at com.ibm.mq.jms.MQQueueConnectionFactory.createQueueConnection(MQQueueConnectionFactory.java:121) 
at com.ibm.mq.jms.MQQueueConnectionFactory.createConnection(MQQueueConnectionFactory.java:1038)

What causes this error and how can I fix this? and why does this error arises only when I deployed the project in my local server?

回答1:

When using JMS and you get an exception but don't know the cause, you might often find more information in one or more linked exceptions, which you can see with something like the following:

System.out.println(jmsex);
Throwable innerException = jmsex.getLinkedException();
if (innerException != null) {
  System.out.println("Inner exception(s):");
}
while (innerException != null) {
  System.out.println(innerException);
  innerException = innerException.getCause();
}

These inner/linked exceptions are likely to contain an MQ reason code.

In your case, it should hopefully give some clues to why the connection has failed. For example, the queue manager name is wrong, the queue manager is not running, some internal problem within the client...

If you find more info but you're still struggling to work out what is going wrong, post the details you find and I can try to advise further.