JimmyD
JimmyD

Reputation: 2759

Connecting to MQ manager get MQ error 2495

We have an application that was fully working in staging but when we deploy it on production we are getting MQ error 2495. We are running the application in a Tomcat 8.5 and we are using the same MQ libraries (8.0.0.6). The server OS is Windows.

The code for reading the message from the MQ looks like:

MQEnvironment.hostname = queueSettings.getServer();
        MQEnvironment.channel = queueSettings.getChannel();
        MQEnvironment.port = queueSettings.getPort();

        MQQueueManager queueManager = new MQQueueManager(queueSettings.getQueueManager());

        int openOptions = CMQC.MQCBDO_FAIL_IF_QUIESCING | CMQC.MQOO_INPUT_SHARED | CMQC.MQOO_BROWSE;

        MQQueue queue = queueManager.accessQueue(queueSettings.getQueue(), openOptions);

De full stacktrace of the error looks like:

com.ibm.mq.MQException: MQJE001: Completion Code '2', Reason '2495'.
at com.ibm.mq.MQSESSION.(MQSESSION.java:2063)
at com.ibm.mq.MQSESSION.getSession(MQSESSION.java:2103)
at com.ibm.mq.MQManagedConnectionJ11.(MQManagedConnectionJ11.java:207)
at com.ibm.mq.MQBindingsManagedConnectionFactoryJ11._createManagedConnection(MQBindingsManagedConnectionFactoryJ11.java:185)
at com.ibm.mq.MQBindingsManagedConnectionFactoryJ11.createManagedConnection(MQBindingsManagedConnectionFactoryJ11.java:230)
at com.ibm.mq.StoredManagedConnection.(StoredManagedConnection.java:96)
at com.ibm.mq.MQSimpleConnectionManager.allocateConnection(MQSimpleConnectionManager.java:194)
at com.ibm.mq.MQQueueManagerFactory.obtainBaseMQQueueManager(MQQueueManagerFactory.java:758)
at com.ibm.mq.MQQueueManagerFactory.procure(MQQueueManagerFactory.java:706)
at com.ibm.mq.MQQueueManagerFactory.constructQueueManager(MQQueueManagerFactory.java:670)
at com.ibm.mq.MQQueueManagerFactory.createQueueManager(MQQueueManagerFactory.java:145)
at com.ibm.mq.MQQueueManager.(MQQueueManager.java:675)
at com.atlascopco.cpq.connections.MQConnection.readMessagesFromQueue(MQConnection.java:92)
at com.atlascopco.cpq.tasks.ResponseHandlerTask.run(ResponseHandlerTask.java:43)
at java.util.TimerThread.mainLoop(Unknown Source)
at java.util.TimerThread.run(Unknown Source)
Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2495;AMQ8568: The native JNI library 'mqjbnd64' was not found. For a client installation this is expected. [3=mqjbnd64]
at com.ibm.mq.jmqi.local.LocalMQ.loadLib(LocalMQ.java:1202)
at com.ibm.mq.jmqi.local.LocalMQ$1.run(LocalMQ.java:272)
at java.security.AccessController.doPrivileged(Native Method)
at com.ibm.mq.jmqi.local.LocalMQ.initialise_inner(LocalMQ.java:260)
at com.ibm.mq.jmqi.local.LocalMQ.initialise(LocalMQ.java:223)
at com.ibm.mq.jmqi.local.LocalMQ.(LocalMQ.java:1255)
at com.ibm.mq.jmqi.local.LocalServer.(LocalServer.java:219)
at sun.reflect.GeneratedConstructorAccessor10933.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.ibm.mq.jmqi.JmqiEnvironment.getInstance(JmqiEnvironment.java:656)
at com.ibm.mq.jmqi.JmqiEnvironment.getMQI(JmqiEnvironment.java:590)
at com.ibm.mq.MQSESSION.(MQSESSION.java:2056)
... 15 common frames omitted
Caused by: java.lang.UnsatisfiedLinkError: no mqjbnd64 in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.ibm.mq.jmqi.local.LocalMQ.loadLib(LocalMQ.java:1146)
... 27 common frames omitted

How can I find the issue?

Upvotes: 2

Views: 7980

Answers (1)

JoshMc
JoshMc

Reputation: 10642

The issue is in your stack trace:

Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2495;AMQ8568: The native JNI library 'mqjbnd64' was not found. For a client installation this is expected. [3=mqjbnd64]
Caused by: java.lang.UnsatisfiedLinkError: no mqjbnd64 in java.library.path

This is documented on the IBM MQ Knowledge center page "Configuring the Java Native Interface (JNI) libraries"

On windows the default location for the libraries are below:

MQ_INSTALLATION_PATH\java\lib (32-bit libraries)
MQ_INSTALLATION_PATH\java\lib64 (64-bit libraries)

You can specify the location of this library one of two ways (both examples below would be for a 64bit JRE if MQ is installed in the default location, if you are running a 32bit JRE use the lib directory instead of the lib64 directory):

  1. With a JVM argument, for example:
    -Djava.library.path=C:\Program Files\IBM\MQ\java\lib64
  2. Via an OS environment variable. In your case on Windows use:
    set PATH=C:\Program Files\IBM\MQ\java\lib64;%PATH%

Upvotes: 4

Related Questions