views:

36

answers:

2

Have been stuck with this problem for a few hours now, anyone any ideas?

java.lang.NoSuchMethodError: com.ibm.mq.MQException.(Ljava/lang/String;Ljava/lang/String;II)V at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:223) at com.ibm.msg.client.wmq.internal.WMQMessageConsumer.checkJmqiCallSuccess(WMQMessageConsumer.java:123) at com.ibm.msg.client.wmq.internal.WMQConsumerShadow.getMsg(WMQConsumerShadow.java:1198) at com.ibm.msg.client.wmq.internal.WMQSyncConsumerShadow.receiveInternal(WMQSyncConsumerShadow.java:233) at com.ibm.msg.client.wmq.internal.WMQConsumerShadow.receive(WMQConsumerShadow.java:922) at com.ibm.msg.client.wmq.internal.WMQMessageConsumer.receive(WMQMessageConsumer.java:450) at com.ibm.msg.client.jms.internal.JmsMessageConsumerImpl.receiveInboundMessage(JmsMessageConsumerImpl.java:742) at com.ibm.msg.client.jms.internal.JmsMessageConsumerImpl.receive(JmsMessageConsumerImpl.java:423) at com.ibm.mq.jms.MQMessageConsumer.receive(MQMessageConsumer.java:258)

Am getting this error when i put the message using MQ native libraries and i read them using JMS API's. The jms read fails throwing the exception above. I am also using jms Selector which seems to be causing the problem. with out the selector everything works fine. TIA.

A: 

You've got wrong version of MQ libraries. Try to run your code against the newest versions.

mgamer
i am using the latest MQ libraries (MQ v. 7). I have narrowed down the scenario to this. I put the Message via MQ libraries and read the same using JMS API's.
hakish
A: 

Finally i was able to resolve this, it all had to do with how the selector is created. The difference was that MQ API's have correlation id as bytes array where as JMS takes it as a string. Due to this the Selector was unable to select the message and was throwing the posted error. The error is not at all debug friendly hence had to do a lot of trial and error. Anyways now this works so i am glad. Below is the code change i had to do for this:

//String selector = "JMSCorrelationID = '" + corleationID + "'"; before change

        StringBuffer fBuf = new StringBuffer("JMSCorrelationID = 'ID:");
        byte[] correlBytes = corleationID.getBytes();
        for(int i=0; i<24; i++) {
          if (i>=correlBytes.length) {
            fBuf.append("00");
          } else {
            byte b = correlBytes[i];
            String hexStr = Integer.toHexString(b);
            // -ve values produce 8 char results
            if (hexStr.length()>2) hexStr = hexStr.substring(hexStr.length()-2);
            // small values produce 1 char results
            if (hexStr.length()<2) fBuf.append("0");
            fBuf.append(hexStr);
          }
        }
        fBuf.append("'");
        String filter = fBuf.toString();
        System.out.println("creating receiver with filter: "+filter);
        QueueReceiver queueReceiver = queueSession.createReceiver(inQueue,filter);

// QueueReceiver queueReceiver = queueSession.createReceiver(inQueue, selector);

Referred the code from IBM docs.

hakish