EDIT: I didn't solve this particular error, but when I "downgraded" my sending functions so that multithreading was not supported, I didn't get any of these errors. That means my multithreading functions don't have enough protection - so this bug trace was part of a larger problem.
I'm having trouble understanding this stack trace and error message in my code. I am sending a lot of messages.ObjectMessage objects over a network. This object has an object packaged inside it, and an enum (type events.Events) to tell the client what sort of message it is.
Sometimes (not always) I get the following crash:
My main problem is I'm having trouble understanding that first line - "cannot assign instance of messages.ObjectMessage to field messages.BigMessage.event of type events.Events in instance of messages.ObjectMessage". Is it trying to assign an ObjectMessage to an events field? Confused :roll:
Thanks for any insight! [ June 20, 2008: Message edited by: Joseph Macer ]
In general, a ClassCastException is assigned (as you thought) when you try to assign one type of object to an object to which it is not compatible. for example,
What particularly is causing it in your case is difficult to tell without the exact code, but from your stack trace I can take some guesses here. You said you are sending ObjectMessages across a network. It would appear the client code tries to read the message and assign it to a BigMessage field. However, if the message being sent is not a BigMessage, this would cause the problem. Does that make sense?
Joined: Apr 20, 2008
Yea, though in this case I'm pretty sure it was a problem with sending multiple objects. When I had a poorly-implemented multithreaded sending function, I got the above error occassionally. When I protected my output stream, I didn't. So in this case I think it was essentially a stream issue. If it ever pops up again, I'll know something else is amiss.
subject: [closed] Understanding class casting exceptions