Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

BytesMessage problem

843830Jun 24 2003 — edited Jul 12 2006
I am trying to send and receive a BytesMessage and when I try to read back a BytesMessage I am getting the exception:

java.lang.ClassCastException: com.ibm.jms.JMSTextMessage

I know this means that it is expecting a TextMessage, but why is this? I understood that if you send a BytesMessage, it should return one?

Here is the abbreviated code:

Message inMessage = null;
javax.jms.BytesMessage outMessage = session.createBytesMessage();
outMessage.writeBytes(getMessage.getBytes()); //convert string to bytes
queueSender.send(outMessage);
session.commit();
System.out.println("Reading the reply back again");
inMessage = queueReceiver.receive(60000);
javax.jms.BytesMessage abytemsg = (javax.jms.BytesMessage) inMessage;


Any hint would be helpful at this point. Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 9 2006
Added on Jun 24 2003
6 comments
594 views