Nastya_KhovrinastephanustsOlga_T
I have used the second code to connect to IBM MQ. But i am getting error as mentioned below when i run this through soapui.
My code:
import com.ibm.msg.client.wmq.*;
import com.ibm.mq.jms.*;
import javax.jms.*;
//public void testMQConnectionMode() throws JMSException {
// MQConnectionFactory qcf = 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)));
//}
MQQueueConnectionFactory qcf = new MQQueueConnectionFactory();
// Host and port settings have their usual meanings
qcf.setHostName ("hostname");
qcf.setPort (portno);
// Queue manager and channel — the W-MQ administrator should
// supply these
qcf.setQueueManager ("Queuemanager");
qcf.setChannel ("channelname");
// Although there are many possible values of transport type,
// only 'client' and 'bindings' work in a Java client. Bindings
// is a kind of in-memory transport and only works when the client
// and the queue manager are on the same physical host. In most
// cases we need 'client'.
qcf.setTransportType (WMQConstants.WMQ_CM_BINDINGS);
QueueConnection qc = qcf.createQueueConnection ();
// QueueConnection qc = qcf.createQueueConnection ("Username","password\$"); //set credentials
qc.start();
// Create a queue and a session
Queue q = new MQQueue ("MQ");
Queue q1 = new MQQueue ("MQ1");
QueueSession s = qc.createQueueSession (false, Session.AUTO_ACKNOWLEDGE);
// Create and send a TextMessage
QueueSender qs = s.createSender (q);
Message m = s.createTextMessage ("Hello, World!");
qs.send (m);
// Receive a TextMessage
QueueReceiver qr = s.createReceiver(q1);
qr.receive();
Error:
Tue Oct 16 16:36:13 IST 2018:ERROR: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.
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.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.ibm.msg.client.commonservices.j2se.NLSServices.createException(NLSServices.java:313)
at com.ibm.msg.client.commonservices.nls.NLSServices.createException(NLSServices.java:388)
at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createV7ProviderConnection(WMQConnectionFactory.java:7178)
at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createProviderConnection(WMQConnectionFactory.java:6583)
at com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl.createConnection(JmsConnectionFactoryImpl.java:295)
at com.ibm.mq.jms.MQConnectionFactory.createCommonConnection(MQConnectionFactory.java:6232)
at com.ibm.mq.jms.MQQueueConnectionFactory.createQueueConnection(MQQueueConnectionFactory.java:115)
at javax.jms.QueueConnectionFactory$createQueueConnection.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
at Script1.run(Script1.groovy:29)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:90)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:141)
at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:250)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: com.ibm.mq.jmqi.local.LocalMQ$3: CC=2;RC=2495;AMQ8598:
-----------------------------------------------------------------------
| Failed to load the WebSphere MQ native JNI library: 'mqjbnd'.
|
| The JVM attempted to load the platform native library 'mqjbnd',
| which was mapped to the filename: 'mqjbnd.dll'.
|
| When attempting to load the library, the JVM reported the error
| message:
| 'no mqjbnd in java.library.path'
|
| The JVM's bit-size is: '64'
|
| The library path which was used to locate this library was:
| '*** Configured java.library.path **********************************
| "C:\Program Files\SmartBear\SoapUI-5.3.0/bin"
| ********************************************************************'
|
| Check that the bit size of the JVM matches the bit size of the first
| native library file located within this java.library.path directory
| list.
|
| The native library 'mqjbnd' is used by the WebSphere MQ classes for
| Java and WebSphere MQ classes for JMS when creating a connection to
| the queue manager using a 'bindings' mode connection. A bindings
| mode connection is a connection which uses the system's memory to
| communicate with the queue manager, as opposed to a 'client' mode
| connection which uses a TCP/IP socket.
|
| In order to communicate with a queue manager using a bindings mode
| connection, the queue manager must be located on the same system as
| the WebSphere MQ classes for Java/JMS. If this is not the case in
| your environment, consider reconfiguring the application to utilise
| client mode connections.
-----------------------------------------------------------------------
at com.ibm.mq.jmqi.local.LocalMQ.loadLib(LocalMQ.java:1125)
at com.ibm.mq.jmqi.local.LocalMQ.access$300(LocalMQ.java:166)
at com.ibm.mq.jmqi.local.LocalMQ$1.run(LocalMQ.java:299)
at java.security.AccessController.doPrivileged(Native Method)
at com.ibm.mq.jmqi.local.LocalMQ.initialise_inner(LocalMQ.java:285)
at com.ibm.mq.jmqi.local.LocalMQ.initialise(LocalMQ.java:250)
at com.ibm.mq.jmqi.local.LocalMQ.<init>(LocalMQ.java:1187)
at com.ibm.mq.jmqi.local.LocalServer.<init>(LocalServer.java:188)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.ibm.mq.jmqi.JmqiEnvironment.getInstance(JmqiEnvironment.java:707)
at com.ibm.mq.jmqi.JmqiEnvironment.getMQI(JmqiEnvironment.java:639)
at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createV7ProviderConnection(WMQConnectionFactory.java:7170)
... 15 more
Caused by: java.lang.UnsatisfiedLinkError: no mqjbnd in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.ibm.mq.jmqi.local.LocalMQ.loadLib(LocalMQ.java:1087)
... 29 more
Any answer why this error is coming?