Multiple web apps in tomcat connecting Websphere MQ
I am running two grails web applications in single instance of tomcat 7, both trying to connect to websphere MQ publishing and receiving messages. First one that gets loaded works well but second one we have following error. If I deploy both of them in different instances of tomcat on same machine it works well but error below is raised when I run both applications in same instance.
20开发者_如何学JAVA11-08-30 14:09:24,661 [Thread-5] [uk.co.pershing.jbf.messaging.ReaderListener] [ERROR] - Exception Occured ... com.ibm.msg.client.jms.DetailedJMSException: JMSFMQ6312: An exception occurred in the Java(tm) MQI. The Java(tm) MQI has thrown an exception describing the problem. See the linked exception for further information. Linked Exception is com.ibm.mq.jmqi.JmqiException: CC=2;RC=2495;AMQ8568: The native JNI library 'mqjbnd' was not found. [3=mqjbnd] 2011-08-30 14:09:24,661 [Thread-5] [uk.co.pershing.jbf.servlet.BusStartupServlet] [ERROR] - uk.co.pershing.jbf.messaging.config.ConfigurationException: com.ibm.msg.client.jms.DetailedJMSException: JMSFMQ6312: An exception occurred in the Java(tm) MQI. The Java(tm) MQI has thrown an exception describing the problem. See the linked exception for further information.
The Java Virtual Machine only allows JNI libraries to be loaded once. If you are trying to load Websphere-MQ JNI libraries from the applications, then the application which loads first will have exclusive access to the JNI libraries through its application-specific ClassLoader.
With separate Tomcat instances there is only one application per Tomcat JVM attempting to load the JNI libraries, so it isn't an issue.
The solution to this is to load the JNI libraries from the Tomcat ClassLoader, by placing the Websphere-MQ JNI jars in the Tomcat lib/ directory instead of the application's lib/ directory. Then, the Tomcat ClassLoader will load the JNI libraries and they will be accessible by both applications.
精彩评论