java.lang.UnsatisfiedLinkError occurs when connecting to a queue manager

Technote (troubleshooting)


Problem(Abstract)

Your MQ Java™ or JMS application attempts to connect to a local queue manager but fails with a java.lang.UnsatisfiedLinkError.

Cause

In order to establish a connection to a local queue manager, often called a "bindings" connection, the MQ Java and JMS classes must load one or more native libraries. When java virtual machine cannot find these native libraries, the connection attempt fails with an exception similar to the following:

    java.lang.UnsatisfiedLinkError: mqjbnd (A file or directory in the path name does not exist.)
    at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:994)
    at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:958)
    at java.lang.System.loadLibrary(System.java:453)
    at com.ibm.mq.jmqi.local.LocalMQ.loadLib(LocalMQ.java:1055)

    ...


Environment

In order to establish a bindings connection to a local queue manager, you must have installed MQ on the machine where the java or JMS application is running. If MQ is not installed locally, or if the target queue manager is on a different system, you must use a client connection instead.

When the target queue manager is running on the local system, your environment must be configured to allow the Java virtual machine can find the MQ native libraries. Follow the instructions below to configure the environment for MQ applications deployed in WebSphere Application Server and for MQ applications running in other Java environments.


Resolving the problem


MQ applications in WebSphere Application Server

WebSphere Application Server V7.0 and later uses the MQ resource adapter to connect to queue managers. Before attempting a bindings connection it is important to configure the "Native library path" on the MQ resource adapter. If your application is running in the client container, you should set the MQ_INSTALL_ROOT property on the launchClient command instead.

WebSphere Application Server V6.1 does not use the MQ resource adapter. Instead, you must set the MQ_INSTALL_ROOT variable to point to the directory containing the MQ native libraries.

The native library path should be the java/lib64 subdirectory of your MQ installation if you are using a 64-bit Java virtual machine, or the java/lib subdirectory for 32-bit Java virtual machines. MQ V7.1 and later on Linux and UNIX, and all versions of MQ on Windows, can be installed in locations other than the default installation directories shown here:


    AIX 64-bit and 32-bit native paths

    /usr/mqm/java/lib64
    /usr/mqm/java/lib

    HP-UX, Linux and Solaris 64-bit and 32-bit native paths

    /opt/mqm/java/lib64
    /opt/mqm/java/lib

    Windows 64-bit and 32-bit native paths for IBM MQ V8.0

    C:\Program Files\IBM\WebSphere MQ\java\lib64
    C:\Program Files\IBM\WebSphere MQ\java\lib

    Windows 64-bit and 32-bit native paths for WebSphere MQ V7.5, V7.1, V7.0 and V6.0

    C:\Program Files (x86)\IBM\WebSphere MQ\java\lib64
    C:\Program Files (x86)\IBM\WebSphere MQ\java\lib

    IBM i native path

    /QIBM/ProdData/mqm/java/lib



Refer to the following documentation for more information on configuring the WebSphere MQ native library path in different versions of WebSphere Application Server:

    WebSphere Application Server V8.5.5 and V8.5

    WebSphere Application Server V8.0


    WebSphere Application Server V7.0

    WebSphere Application Server V6.1




MQ V8.0, V7.5 and V7.1 applications on Linux, UNIX and Windows

Use the setmqenv command to set up your environment for the MQ installation. In order for your java virtual machine to find the MQ native libraries, you must use either the -k or -l (ell) option to modify your library path, as well as the -x option to choose either 64-bit or 32-bit libraries. On Linux and UNIX systems, be sure to use the dot syntax to source the setmqenv command, for example:

    Using setmqenv on Linux and UNIX


    sh> . /opt/mqm80/bin/setmqenv -n Installation1 -k -x64


    Using setmqenv on Windows


    C:\> setmqenv -n Installation1 -k -x64



If you do not wish to modify your library path in the environment, specify the MQ native library path on the command line when starting the Java virtual machine, for example:

    Setting the native library path manually on Linux and UNIX


    sh> . /opt/mqm75/bin/setmqenv -n Installation1
    sh> java -Djava.library.path=/opt/mqm/java/lib64 ...


    Setting the library path manually on Windows


    C:\> setmqenv -n Installation1
    C:\> java -Djava.library.path="C:\Program  Files\IBM\WebSphere  MQ\java\lib" ...



Refer to the following documentation for more information on using the setmqenv command to configure the environment to find the MQ JMS native libraries:

    WebSphere MQ V7.5


    WebSphere MQ V7.1



MQ applications on Linux, UNIX, Windows and IBM i

If you are running MQ V7.1 or later on Linux, UNIX or Windows, the setmqenv instructions above provide the best method for configuring your environment. However, these instructions will work for all releases of MQ on Linux, UNIX, Windows and IBM i.

The MQ installer sets up all of the environment variables on Windows. On Linux and UNIX systems, and in the IBM i Qshell, MQ provides the setjmsenv command to configure the environment for a 32-bit Java virtual machine. MQ V7.0 and later on Linux and UNIX also provides the setjmsenv64 command to do the same for a 64-bit Java virtual machine. Be sure to use the dot syntax to source setjmsenv and setjmsenv64 on Linux and UNIX, and in the IBM Qshell. Once the MQ environment variables have been set, use the runjms script to start the Java virtual machine, for example:

    Using setjmsenv and runjms on Linux and UNIX


    sh> . /opt/mqm/bin/setjmsenv
    sh> runjms java arguments...


    Using setjmsenv64 and runjms on Linux and UNIX


    sh> . /opt/mqm/bin/setjmsenv64
    sh> runjms java arguments...


    Using runjms on Windows


    C:\> runjms java arguments...


    Using setjmsenv and runjms in the IBM i Qshell


    ===> . /QIBM/ProdData/mqm/java/bin/setjmsenv
    ===> runjms java arguments...


If you prefer not to use the runjms script, you can specify the MQ native library path on the Java virtual machine command line instead. For example:

    Setting the native library path manually on Linux and UNIX


    sh> . /opt/mqm/bin/setjmsenv
    sh> java -Djava.library.path=$MQ_JAVA_LIB_PATH java arguments...

    Setting the 64-bit native library path manually on Linux and UNIX


    sh> . /opt/mqm/bin/setjmsenv64
    sh> java -Djava.library.path=$MQ_JAVA_LIB_PATH java arguments...


    Setting the native library path manually on Windows


    C:\> java -Djava.library.path=%MQ_JAVA_LIB_PATH% java arguments...


    Setting the native library path manually in the IBM i Qshell


    ===> . /QIBM/ProdData/mqm/java/bin/setjmsenv
    ===> java -Djava.library.path=$MQ_JAVA_LIB_PATH java arguments...



Refer to the following documentation for more information on the MQ environment variables used to find the MQ JMS native libraries, and about the JMS scripts provided by MQ:


Related information

UnsatisfiedLinkError: mqjbnd (Not found in java.library
A Japanese translation is available

Cross reference information
Segment Product Component Platform Version Edition
Application Servers WebSphere Application Server Java Message Service (JMS) AIX, HP-UX, IBM i, Linux, Solaris, Windows, z/OS 8.5.5, 8.5, 8.0, 7.0, 6.1

Product Alias/Synonym

WMQ MQ

Rate this page:

(0 users)Average rating

Add comments

Document information


More support for:

WebSphere MQ
Java

Software version:

6.0, 7.0, 7.1, 7.5, 8.0

Operating system(s):

AIX, HP-UX, IBM i, Linux, Solaris, Windows

Software edition:

All Editions

Reference #:

1248900

Modified date:

2014-06-12

Translate my page

Machine Translation

Content navigation