activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james.strac...@gmail.com>
Subject Re: ClassCastException on MessageObject's object
Date Tue, 01 May 2007 04:17:26 GMT
If you get a ClassCastException yet the object seems to be of the
correct class name, then it looks like a class loader issue (multiple
versions of the same class on the classpath). Otherwise if it was a
serialization issue, you wouldn't get an object you can inspect.


On 4/30/07, nlif <naaman@dbnet.co.il> wrote:
>
> 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
> [hashcode=31922829]
>
>
> 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.
>
> Thanks,
> Naaman
> --
> View this message in context: http://www.nabble.com/ClassCastException-on-MessageObject%27s-object-tf3671759s2354.html#a10260020
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 
James
-------
http://macstrac.blogspot.com/

Mime
View raw message