activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nlif <>
Subject ClassCastException on MessageObject's object
Date Mon, 30 Apr 2007 20:26:06 GMT

Hi all,

We have a strange problem, maybe someone has seen this or has an idea:

In our MessageListener, we cast the Message into ObejctMessage, and then
call getObject() to get the actual object we sent. Upon trying to cast the
object to the proper class (SendMobileNotification), we get a
ClassCastException. To make things even more strange, this is sporadic: it
doesn't always happen, and we can't figure out the exact circumstances under
which it does happen.

Here is the relevant code:

public void onMessage(Message message) {
		try {
			ObjectMessage objectMessage = (ObjectMessage) message;
                        Serializable object = objectMessage.getObject();

			logger.debug("Message SHOULD BE type: " +
SendMobileNotification.class.getName() + " [hashcode=" +
SendMobileNotification.class.hashCode() + " , serialVersionUID=" +
SendMobileNotification.serialVersionUID + "]");

			logger.debug("Message IS type: " + object.getClass().getName() + "
[hashcode=" + object.getClass().hashCode() + "]");

			SendMobileNotification  sendMobileNotification = (SendMobileNotification)
(object); // this line throws ClassCastException

And here's what's written to the log:

DEBUG - Message SHOULD BE type: com.softcom.messages.SendMobileNotification
[hashcode=4050691 , serialVersionUID=-11111111111111]

DEBUG - Message IS type: com.softcom.messages.SendMobileNotification

Is this an ActiveMQ issue?
Is this a class loader issue? If so, how can something like this happen?
Is it related to Serialization?

Any help will be appreciated.

View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message