Thursday, May 22, 2008

Problem connecting to Websphere MQ in binding mode

Today, I have run into a problem in sending a message to Websphere MQ. I just want to send a message from a stateless session bean running in JBoss 4.0.5 on Solaris box. Both my application server and Websphere MQ are running on the machine. So, I decided to connect to MQ in a binding mode. Simple task isn’t it?
I quickly wrote a simple MQ java client, modified the session bean to call the mq client , deployed the application, run a sample test and expected the message to show up in the MQ queue. But, instead I got an exception reported in the application server log. Below is the stack trace of the exception.


java.lang.UnsatisfiedLinkError: no mqjbnd05 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1517)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:834)
at com.ibm.mq.MQSESSION.loadLib(MQSESSION.java:872)
at com.ibm.mq.server.MQSESSION$1.run(MQSESSION.java:228)
at java.security.AccessController.doPrivileged(Native Method)
at com.ibm.mq.server.MQSESSION.(MQSESSION.java:222)
at com.ibm.mq.MQSESSIONServer.getMQSESSION(MQSESSIONServer.java:70)
at com.ibm.mq.MQSESSION.getSession(MQSESSION.java:492)
at com.ibm.mq.MQManagedConnectionJ11.(MQManagedConnectionJ11.java:168)
at com.ibm.mq.MQBindingsManagedConnectionFactoryJ11._createManagedConnection(MQBindingsManagedConnectionFactoryJ11.java:179)
at com.ibm.mq.MQBindingsManagedConnectionFactoryJ11.createManagedConnection(MQBindingsManagedConnectionFactoryJ11.java:215)
at com.ibm.mq.StoredManagedConnection.(StoredManagedConnection.java:84)
at com.ibm.mq.MQSimpleConnectionManager.allocateConnection(MQSimpleConnectionManager.java:168)
at com.ibm.mq.MQQueueManagerFactory.obtainBaseMQQueueManager(MQQueueManagerFactory.java:772)
at com.ibm.mq.MQQueueManagerFactory.procure(MQQueueManagerFactory.java:697)
at com.ibm.mq.MQQueueManagerFactory.constructQueueManager(MQQueueManagerFactory.java:657)
at com.ibm.mq.MQQueueManagerFactory.createQueueManager(MQQueueManagerFactory.java:153)
at com.ibm.mq.MQQueueManager.(MQQueueManager.java:451)



Just by looking at error message, it is clear that the system can not find library file for mqjbind05 in java’s library path. A quick grep on the system showed that required mq java library file(libmqjbind05.so) is available at /opt/mqm/java/lib.
I thought adding the above directory path to my environment variable $PATH would solve the problem but it did not. Apparently, Solaris does not seem to pick this entry from $PATH variable add to java’s library path. That left me no option but to add the path as VM argument. I did it so by adding
‘-Djava.library.path=/opt/mqm/java/lib’ to my server’s VM arguments. And guess what? It worked!!

No comments: