Accessing MQ with JMS

29,772

Solution 1

This is almost always caused by a combination of an incomplete client install and/or a CLASSPATH issue. Many people grab the jar files rather than performing the complete install and do not necessarily get all of them. In addition to insuring all required binaries are present, using the install media provides several additional capabilities such as diagnostics and trace. It also assures that maintenance can be applied. The WMQ client install media are available for free download as SupportPac MQC7. The CLASSPATH setting should be as described in the WebSphere MQ Using Java manual.

If the client install is performed from the IBM media and the environment is set up as per the docs, this fixes nearly all cases such as you have reported here. There are a few Install Verification Test apps (some of those diagnostics installed with the full media that I mentioned) which are described here and which can help determine if a problem is with the installation or with the code.

Solution 2

Probably a bit late but I had the same problem and found that this can be avoided if you use a different Connection Mode when connecting to a remote Queue. By default the MQConnectionFactory uses WMQ_CM_BINDINGS as it's connection mode. If you change it to WMQ_CM_CLIENT (or whichever connection mode you like that doesn't require native libraries) you should be fine.

@Test
public void testMQConnectionMode() throws JMSException {
    MQConnectionFactory cf = new MQConnectionFactory();
    assertThat(cf.getIntProperty(CommonConstants.WMQ_CONNECTION_MODE), is(equalTo(CommonConstants.WMQ_CM_BINDINGS)));
    cf.setIntProperty(CommonConstants.WMQ_CONNECTION_MODE, CommonConstants.WMQ_CM_CLIENT);
    assertThat(cf.getIntProperty(CommonConstants.WMQ_CONNECTION_MODE), is(equalTo(CommonConstants.WMQ_CM_CLIENT)));
}

Solution 3

Agree with Johnam, it happened because the ConnectionFactory set as server by default, it need to be set as client, you said that it works on same machine. Because I also met the same situation, it run when on same machine, in this case because your machine is as WMQ Server so do the program, but when you run on different machine then your program must set as client.

I fix it using set some parameter on ConnectionFactory:

<bean id="mqConnectionFactory" class="com.ibm.mq.jms.MQConnectionFactory">
....
<property name="transportType" value="1" />
<property name="clientReconnectTimeout" value="2" /> 
<property name="clientReconnectOptions" value="0" />
</bean>

Solution 4

The VM parameter -Djava.library.path=/opt/mqm/java/lib64 works for me. My environment is 64bit Suse with MQ installed and my program is using 'Bindings' transport type

Share:
29,772
hakish
Author by

hakish

Currently working on Big data technologies and exploring the field of data science.

Updated on September 19, 2020

Comments

  • hakish
    hakish almost 4 years

    i am using MQ7 and trying to access a queue with JMS api's. Getting this error. Has anyone seen it before? How do i resolve this? TIA

    Exception in thread "main" 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.

    Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2495;AMQ8568: The native JNI library 'mqjbnd' was not found. [3=mqjbnd]

    Caused by: java.lang.UnsatisfiedLinkError: no mqjbnd in java.library.path

  • hakish
    hakish almost 14 years
    The scenario is i am using a java program to access a MQ queue deployed on a separate machine via JMS,so i got all the required MQ client libs from the server, the weirdness lies in the fact that the same program runs perfectly on the server where MQ is deployed with the same jars in classpath, may be it has something to do with java.library.path prop, any more ideas. :)
  • duffymo
    duffymo almost 14 years
    The error message clearly says that java.library.path is missing mqjbnd. If you go to the server on which it works, I'm sure you'll find that its java.library.path is set properly. Make yours the same and it'll work, I'm sure.
  • T.Rob
    T.Rob almost 14 years
    This is the reason that IBM does not support this type of install. If you use the MQC7 SupportPac to install the client then you get all the required libs and jars as well as diagnostic utilities. According to your comment, the one place where the install media was used, it works. Why not use the documented and supported procedure to install the client libs? Then you could open PMRs if needed and apply maintenance. Or are these things not important for your application?
  • hakish
    hakish almost 14 years
    it works when the client and server reside in the same machine, but not in separate..
  • T.Rob
    T.Rob almost 14 years
    Or from my perspective, it works on the machine where IBM's install media was run and not on the machine where the jars were installed by copying them over. As an IBM consultant specializing in WMQ I see this a lot. The first thing I get my clients to do is run the supported install as per the documentation. This fixes 80% ~ 90% of the problems such as you are reporting. If you are unwilling to run the install media on the client machine, I can't help you further. If it still doesn't work with the full install, I'd ask to see the output of the Initial Verification Test program run.
  • K.M
    K.M almost 13 years
    I have installed it using the process mentioned in the IBM manual Chapter 3 "Installing a Websphere MQ Client", on Linux 64 bit. Following command gives me this result. dspmqver -p 63 Name: WebSphere MQ Version: 7.0.1.6 CMVC level: p701-106-110725 BuildType: IKAP - (Production) . . . Name: IBM WebSphere MQ Version: 7.0.1.6 CMVC Level: k701-106-110721 mqjbnd=CC=2;RC=2495;AMQ8568: The native JNI library 'mqjbnd' was not found. [3=mqjbnd]::no mqjbnd in java.library.path Build Type: Production DistHub Build Level: DH610-GOLD Webscale Distribution Hub Core
  • Betlista
    Betlista over 10 years
    @T.Rob hi, can you please fix the link for "There are a few Install Verification Test apps ..."? Thanks ;-)
  • T.Rob
    T.Rob over 10 years
    @Betlista perhaps the server was down? The link works for me now. However it is for v7.0 and so here's a current one: Post installation setup for WebSphere MQ classes for JMS applications - v7.5
  • Betlista
    Betlista over 10 years
    Thanks, new links works fine, while the previous one still not working (empty page shows here in Europe), 7.5 is better anyway ;-) I found this one (www-01.ibm.com/support/docview.wss?uid=swg21413508) really helpful, but its not working anyway :-( All properties are configured, but dspmqver.exe shows "The native JNI library '?' was not found." I didn't find good step by step tutorial how to make samples working...
  • T.Rob
    T.Rob over 10 years
    You may need to clear cookies. The Infocenter shows up blank for me a lot too, but when I clear cookies (and sometimes cache) it comes right back. Note that the Infocenters are served from different IBM sites beginning with v7.5 so it behaves differently. At the moment I have access to all four Infocenters from v6.0 to v7.5. Latest Firefox, Win 7x64, NoScript, USA IP addy.
  • T.Rob
    T.Rob over 10 years
    Did you do setmqinst after install?
  • Betlista
    Betlista over 10 years
    @T.Rob after running setmqinst it told me to restart PC, what I didn't before probably, now the dspmqver.exe works. I also found that those links I refered to as not working does not work in Chrome, but they work fine in Firefox.
  • Carl Smotricz
    Carl Smotricz over 7 years
    As someone also struggling with this problem, I'd like to clarify that switching to WMQ_CM_CLIENT is necessary but not sufficient. I also needed to include "com.ibm.mq.jmqi.jar" in my set of library jars. Just for info, this in turn pulls in jms.jar, com.ibm.mq.headers.jar and com.ibm.mq.jar . I'm still seeing (other) problems, though, so more jars may be needed.