Search code examples
javatomcatspring-bootibm-mqmq

Error instantiating MQ ConnectionFactory object


First of all I would like to apologize for a little unorganized write up here. I am writing a spring boot application to read a message from the MQ queue.But I am getting an exception while trying to create an instance of the MQXAConnectionFactory object. And I have realized that it is being caused because the MQXAConnectionFactory extends com.ibm.msg.client.jms.admin.JmsJndiConnectionFactoryImpl.

code snippet

    @Value("${ems.mq.cf.hostName}")
    String mqHostName;
    @Value("${ems.mq.cf.port}")
    int mqPort;
    @Value("${ems.mq.cf.queueManager}")
    String mqQueueManager;
    @Value("${ems.mq.cf.channel}")
    String mqChannel;

    private ConnectionFactory mqJmsConnectionFactory() throws JMSException{

    try {

    MQXAConnectionFactory factory=new MQXAConnectionFactory();
    factory.setHostName(mqHostName);
    factory.setPort(mqPort);
    factory.setQueueManager(mqQueueManager);
    factory.setChannel(mqChannel);
    factory.setTransportType(WMQConstants.WMQ_CM_CLIENT);
    return factory;
    }
    catch (JMSException e){
        throw new RuntimeException(e);
    }

}

The problem is that com.ibm.msg.client.jms.admin package does not exist on any of the jar's that I have set on my class path. The solution suggested in the IBM website which reads as follows does not help either.

The type com.ibm.msg.client.jms.admin.JmsJndiDestinationImpl
cannot be resolved. It is indirectly referenced from required .class files.

Local fix

 Import the com.ibm.msg.client.jms.internal from
    wmq.jmsra.rar and add it to the build path.
    You can find the rar file under <WPS_HOME>\lib\WMQ\ra

But this is not an option for me because I am using a local tomcat server and having that file on my class path is not an option for me.

Following ibm jars are on my class path

1. mqjms-7.0.1.0.jar, 
2. ibm-mq-7.0.1.0.jar
3. client.osgi.jms.jar

Any help regarding this would be highly appreciated. Namaste


Solution

  • I have finally figured out the problem. use version 6 or older com.ibm.mq.jar & com.ibm.mqims.jar.

    and then add connector.jar Which seems to be of utmost importance. I got this solution from mqseries.net to add the connector jar

    http://www.mqseries.net/phpBB2/viewtopic.php?t=40546

    posted by gaya3

    Please add, connector.jar ,jta.jar in the build path (connector.jar is there) (looks like the connector.jar might have corrupted or does not have all access privileges)

    check the access privileges are there to do so

    Following jar files has to be there on classpath

    1. com.ibm.mq.jar
    2. com.ibm.mqims.jar
    3. connector.jar (important)
    4. jms.jar