Solving the NameNotFoundException when connecting to IBM MQ through JMS

If you are facing an exception like the one at [0], then the problem might be hard to figure out. Because, if you look at the Queues in the MQ explorer, the queu named FOOQ will be there.

So, the missing part here is the JMS binding of that queue. This takes 10 minutes to solve. Right click on the queue, and select ‘create JMS queue’. Pick the JNDI Context you have created (creating this is out of scope of this post), and just click next, next and finish. Now re-generate the JNDI bindings by running IVTSetup.bat, and copy it over to the client machine and use it.

Your problem should be solved by now and you will be happily putting messages to IBM MQ Queues.

[0] –

TID: [0] [ESB] [2013-03-20 19:01:11,515] ERROR {org.apache.axis2.transport.jms.JMSConnectionFactory} -  Error looking up the JMS destination with name FOOQ of type generic {org.apache.axis2.transport.jms.JMSConnectionFactory}
javax.naming.NameNotFoundException: dynamicQueues/FOOQ
    at com.sun.jndi.fscontext.RefFSContext.getObjectFromBindings(RefFSContext.java:400)
    at com.sun.jndi.fscontext.RefFSContext.lookupObject(RefFSContext.java:327)
    at com.sun.jndi.fscontext.RefFSContext.lookup(RefFSContext.java:146)
    at com.sun.jndi.fscontext.FSContext.lookup(FSContext.java:127)
    at org.wso2.carbon.context.internal.CarbonContextDataHolder$CarbonInitialJNDIContext.lookup(CarbonContextDataHolder.java:1030)
    at javax.naming.InitialContext.lookup(InitialContext.java:411)
    at org.apache.axis2.transport.jms.JMSUtils.lookup(JMSUtils.java:509)
    at org.apache.axis2.transport.jms.JMSUtils.lookupDestination(JMSUtils.java:718)
    at org.apache.axis2.transport.jms.JMSConnectionFactory.getDestination(JMSConnectionFactory.java:198)
    at org.apache.axis2.transport.jms.JMSMessageSender.<init>(JMSMessageSender.java:88)
    at org.apache.axis2.transport.jms.JMSSender.sendMessage(JMSSender.java:120)
    at org.apache.axis2.transport.base.AbstractTransportSender.invoke(AbstractTransportSender.java:112)
    at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
    at org.apache.axis2.description.OutOnlyAxisOperationClient.executeImpl(OutOnlyAxisOperation.java:297)
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
    at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:456)
    at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:57)
    at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:316)
    at org.apache.synapse.endpoints.AbstractEndpoint.send(AbstractEndpoint.java:329)
    at org.apache.synapse.endpoints.AddressEndpoint.send(AddressEndpoint.java:59)
    at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:175)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
    at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:367)
    at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:408)
    at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:219)

    at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)
TID: [0] [ESB] [2013-03-20 19:01:12,045] ERROR {org.apache.synapse.core.axis2.Axis2Sender} -  Unexpected error during sending message out {org.apache.synapse.core.axis2.Axis2Sender}
org.apache.axis2.transport.jms.AxisJMSException: Error looking up the JMS destination with name FOOQ of type generic
    at org.apache.axis2.transport.jms.JMSConnectionFactory.handleException(JMSConnectionFactory.java:228)
    at org.apache.axis2.transport.jms.JMSConnectionFactory.getDestination(JMSConnectionFactory.java:200)
    at org.apache.axis2.transport.jms.JMSMessageSender.<init>(JMSMessageSender.java:88)
    at org.apache.axis2.transport.jms.JMSSender.sendMessage(JMSSender.java:120)
    at org.apache.axis2.transport.base.AbstractTransportSender.invoke(AbstractTransportSender.java:112)
    at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
    at org.apache.axis2.description.OutOnlyAxisOperationClient.executeImpl(OutOnlyAxisOperation.java:297)
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
    at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:456)
    at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:57)
    at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:316)
    at org.apache.synapse.endpoints.AbstractEndpoint.send(AbstractEndpoint.java:329)
    at org.apache.synapse.endpoints.AddressEndpoint.send(AddressEndpoint.java:59)
    at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:175)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
    at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:367)
    at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:408)
    at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:219)

    at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)
Caused by: javax.naming.NameNotFoundException: dynamicQueues/FOOQ
    at com.sun.jndi.fscontext.RefFSContext.getObjectFromBindings(RefFSContext.java:400)
    at com.sun.jndi.fscontext.RefFSContext.lookupObject(RefFSContext.java:327)
    at com.sun.jndi.fscontext.RefFSContext.lookup(RefFSContext.java:146)
    at com.sun.jndi.fscontext.FSContext.lookup(FSContext.java:127)
    at org.wso2.carbon.context.internal.CarbonContextDataHolder$CarbonInitialJNDIContext.lookup(CarbonContextDataHolder.java:1030)
    at javax.naming.InitialContext.lookup(InitialContext.java:411)
    at org.apache.axis2.transport.jms.JMSUtils.lookup(JMSUtils.java:509)
    at org.apache.axis2.transport.jms.JMSUtils.lookupDestination(JMSUtils.java:718)
    at org.apache.axis2.transport.jms.JMSConnectionFactory.getDestination(JMSConnectionFactory.java:198)
    ... 20 more

Solving the IBM MQ client error – no mqjbnd in java.library.path

If you come across this issue when you try to connect a JMS client to IBM MQ (v7.0.x.x), this has nothing to do with any environment variables or VM arguments, at least it wasn’t for me (There are quite a lot of those articles out there, that makes you think this is the problem).

The fix for this will has to be done on the server side. Open the MQ Explorer. Now, if you have not done so already, you need to add your JNDI directory to JMS Administered Objects. In the Connection Factories,  you will note that your factories’ transport type is actually “Binding”. You need to right-click and go to the switch transport option which will have the “MQ Client” option that needs to be selected. Now the transport type will be “Client”. Do this to all Connection Factories that you are connecting to. Now, your configuration will look something like below:

Screen Shot 2013-03-20 at 5.28.49 PM

Now, run your client again, and the error should go away. HTH.

Quick Fix for wsdls generated by Axis2 to run on IBM JDK

Some of you may have come across the problem. WSDLs generated from Axis2 has a problem of malfunctioning with the IBM JDK. (I’m not sure whether this occurs with other JDKs or other environments).

There’s a quick fix that can be done so that these WSDLs function without a glitch on any JDK.

If a <xs:complex> tag has a name attribute, then replace the <xs:sequence> tag it has it’s immediate child by <xs:all>.

ex:

Before fix:
<xs:complexType name=”ServiceBean”>
<xs:sequence>
<xs:element minOccurs=”0″ name=”id” nillable=”true” type=”xs:string” />
<xs:element minOccurs=”0″ name=”path” nillable=”true” type=”xs:string” />
<xs:element maxOccurs=”unbounded” minOccurs=”0″ name=”policyBeans” nillable=”true” type=”ax2100:PolicyBean” />
<xs:element minOccurs=”0″ name=”qName” nillable=”true” type=”xs:string” />
<xs:element maxOccurs=”unbounded” minOccurs=”0″ name=”schemaBeans” nillable=”true” type=”ax2100:SchemaBean” />
<xs:element maxOccurs=”unbounded” minOccurs=”0″ name=”wsdlBeans” nillable=”true” type=”ax2100:WSDLBean” />
</xs:sequence>
</xs:complexType>

After fix:
<xs:complexType name=”ServiceBean”>
<xs:all>
<xs:element minOccurs=”0″ name=”id” nillable=”true” type=”xs:string” />
<xs:element minOccurs=”0″ name=”path” nillable=”true” type=”xs:string” />
<xs:element maxOccurs=”unbounded” minOccurs=”0″ name=”policyBeans” nillable=”true” type=”ax2100:PolicyBean” />
<xs:element minOccurs=”0″ name=”qName” nillable=”true” type=”xs:string” />
<xs:element maxOccurs=”unbounded” minOccurs=”0″ name=”schemaBeans” nillable=”true” type=”ax2100:SchemaBean” />
<xs:element maxOccurs=”unbounded” minOccurs=”0″ name=”wsdlBeans” nillable=”true” type=”ax2100:WSDLBean” />
</xs:all>
</xs:complexType>

Now you’re wsdl should work on any jdk/server without a problem. Do leave a comment if this works. 🙂