Question

I'm working on an EJB3 MDB that listen to a MQ queue in a distant server. All is working fine (MDB triggered when a message is put into the listenned queue) except the treatment done by the MDB. For information, i use WMQ resource adapter to map the queue.

Into the method 'onMessage' of the MDB, i try to cast the given message into the class 'com.ibm.jms.JMSBytesMessage', but i get a strange error message.

The code is the following one (simple for the example):

public void onMessage(Message theMessage) {
  ((JMSBytesMessage) theMessage).readBytes(myBytes);
}

And the exception message:

Exception while reading input request: com.ibm.jms.JMSBytesMessage incompatible with com.ibm.jms.JMSBytesMessage

Ok, the message received should be (and is) type 'com.ibm.jms.JMSBytesMessage', so why the application doesn't work ? Should it be possible that my JBoss server already use another version of the library 'com.ibm.mqjms.jar' (including the JMSBytesMessage class) and cause this kind of error ?

ps: i've deployed the application on a JBoss server version 4.2.3 under linux system. I've already make the application work on my local machine with same version of JBoss server but under window system (same configuration, same libraries, etc.)

Does someone have an idea about the reason of such error ?

Thanks in advance for any help.

Regards,

EDIT: SOLUTION: cast with javax.jms.BytesMessage instead of com.ibm.jms.JMSBytesMessage

Was it helpful?

Solution

Might as well reproduce my comment as answer:

Don't cast to the MQ-specific com.ibm.jms.JMSBytesMessage, cast to the JMS-standard javax.jms.BytesMessage. Coupling your code to the implementation-specific types is counter to what JMS tries to achieve.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top