15

i am trying to access MQ queues using JMS. i am getting the below

java.lang.UnsatisfiedLinkError: no mqjbnd05 in java.library.path

i am passing

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

as the VM argument while running the program in eclipse. This issue is discussed quite a lot on the net but with out any conclusion. Has anyone resolved this? TIA.

Andreas Dolk
  • 113,398
  • 19
  • 180
  • 268
hakish
  • 3,990
  • 7
  • 39
  • 56
  • Did you check if the directory `C:\Program Files\IBM\WebSphere MQ\java\lib` actually contains the native library `mqjbnd05.dll`? – Jesper Jul 20 '10 at 11:21
  • the thing is i dont find this mqjbn05.dll, all i have is mqjbnd.dll the path for which i have specified at the VM arg section – hakish Jul 20 '10 at 11:40

6 Answers6

27

As I had to deal with this error myself; and it took me a lot of time to find the right answer, I'd like to share it with the next one, who comes along this thread...

Actually the solution to the problem was very simple (at least in my case). It was not related to any CLASSPATH, java.library.path or installation issues.

I simply forgot to switch the MQConnectionFactory into the Client mode.

This has to be done, by simply calling

cf.setTransportType(WMQConstants.WMQ_CM_CLIENT);

or

cf.setTransportType(WMQConstants.WMQ_CM_BINDINGS_THEN_CLIENT);

or any other connection type, that fits your needs.
By default, the ConnectionFactory is in "Binding" mode (WMQ_CM_BINDINGS), which is intended for local server installations, as it is is stated in the IBM Documentation:

To connect to a queue manager in bindings mode, a WebSphere MQ classes for JMS application must run on the same system on which the queue manager is running.

This transport type is the same as the XMSC_WMQ_CONNECTION_MODE (WMQConstants.WMQ_CONNECTION_MODE) property, when using JNDI or the JmsFactoryFactory.

The same should apply to the other ConnectionFactory types: MQQueueConnectionFactory, MQTopicConnectionFactory, MQXAConnectionFactory, MQXAQueueConnectionFactory and MQXATopicConnectionFactory

Check the IMB Knowledge Center for more information about the different connection/binding options:

https://www.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.dev.doc/q031720_.htm https://www.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.dev.doc/q030560_.htm

Daniel Rothmaler
  • 560
  • 4
  • 14
  • The error is misleading. This is answer gives a hint of what should happen. You should go to the MQ Explorer and change the transport type to "Client" instead of "Binding". – dev_nut Mar 21 '13 at 17:16
  • Your solution is not actually a solution. You are just working with the CLIENT mode and not BINIDING mode, so by changing the mode your program ran. However, if you still need to use BINDING mode then what you will do ? – Som Nov 21 '17 at 20:13
  • 1
    @Som Well as I wrote in my answer Binding Mode is intended for connections to a local server (on the same machine). So if you actually want to bind to a local MQ Server instance and you are still getting this issue, then you should probably just do what the error message suggests (adding the directory where your `mqjbnd05` is located to your `java.library.path`). If you don't have the dll, than there might be a version conflict. But I have never used Binding Mode myself; so I can't help much with this. – Daniel Rothmaler Nov 24 '17 at 21:32
  • What a ridiculous default. Thanks IBM :-( – mjaggard Oct 04 '18 at 16:06
6

You probably have some older MQ jar files either in your CLASSPATH, in the lib or in the EAR.
Remove them and you should be fine.
You should not put MQ files in your EAR or in the WEB-INF/lib folders. They should be in the classpath of your appserver.

Romain Hippeau
  • 24,113
  • 5
  • 60
  • 79
  • 1
    @hakish - Actually they are, you can access MQ7 with MQ6 and vice-versa, you just cannot use version 7 .dll files with v6 jars. – Romain Hippeau Jul 21 '10 at 04:51
3

I came across this while connecting using IBM MQ api. I didn't find this issue to be related to classpath either.

This happened to me when I instantiated MQQueueManager before setting MQEnvironment's hostname and channel. Just ensure that your code does not do that and that it instantiates the manager after the environment is set. Something like..

MQEnvironment.hostname = "mq hostname";
MQEnvironment.channel = "mq channel";
..more code..
this._queueManager = new MQQueueManager(qManager);

(Observed that it's OK to set MQEnvironment.port after MQQueueManager is initialized, but one would probably initialize everything related to MQEnvironment together)

ObviousChild
  • 119
  • 1
  • 9
1

This can happen if you actually installed MQ Client instead of MQ Server.

IBM has even written a whole help page about it:

WebSphere MQ Client installation missing mqjb*.dll files

Problem(Abstract)

You install the WebSphere MQ Client and notice three dll's are missing from the \Program Files\IBM\WebSphere MQ\Java\lib\ directory.

Symptom

The following dlls appear in the directory on a server install, but are not part of the Java™ client:

  • 03/17/2003 10:59a 19,456 mqjbdf02.dll
  • 03/17/2003 10:59a 57,856 mqjbnd05.dll
  • 03/17/2003 10:59a 36,864 MQXAi02.dll

The subdirectory \jdbc\ appears on the server, but not on the client machine.

  • 03/17/2003 10:59a 61,440 jdbcdb2.dll
  • 03/17/2003 10:59a 61,440 jdbcora.dll

Cause

The files are missing because they are not provided nor needed in a client install.

Resolving the problem

The files are only included in the WebSphere MQ Server product.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
0

Here is an easy recipe: Tell the Java VM to Load the DLL. Is your code similiar, e.g. do you use System.loadLibrary to load mqjbnd05.dll?

If yes - does it work outside eclipse, like starting the application from the command line? If this is the case, you could try starting the whole eclipse IDE with that library path.

And sometimes we have trouble with pathnames that contain spaces. Copy the dll to C:\, put that on the lib path and try again.


Ah, that's the problem, the specified dll is missing. This blog has a solution. Good luck!

Andreas Dolk
  • 113,398
  • 19
  • 180
  • 268
  • 1
    the thing is i dont find this mqjbn05.dll, all i have is mqjbnd.dll the path for which i have specified at the VM arg section – hakish Jul 20 '10 at 11:39
0

In my case when I set the transport type , the error goes away. I was using MQConnectionFactory

mQQueueConnectionFactory.setTransportType( JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);