I'm not quite sure what to make of this problem. I'm getting ClassCastException's deserializing an EJB3 entity bean (as the post title says). The sequence of events is that my client sends an ejb3 entity to the server, to a stateless session bean to persist. The call is made to EntityManager and then (before returning the object to the client) the entity is sent to a jms queue. I've tried placing the entity on the queue both from a @Post-method, and after the call to EntityManager.someMethod() is called. The exception happens when the entity is pulled off the queue (still on the server).
The exception message says something to the effect of: ClassCastException: cannot cast org.hibernate.collections.PersistentBag to java.lang.Integer.
I am extremely stumped. It almost sounds like the entity isn't detached, because it still has hibernate references in the underlying collections. I googled, and I saw talk about trying to write methods to "clense" the POJO of hibernate collections. I fear that this can be difficult and error prone given the potential complexity of the object graph. And besides, I thought the point of EJB3 was to avoid things like that.
Any help would be greatly appreciated! Thanks in advance.
If anyone else could weigh in on the issue of "cleansing" POJOs of Hibernate, I'd be very interested. Is crossposting in the CMP forum appropriate, or against posting guidelines?
Related topic and code samples with some ideas to address > http://www.jboss.org/index.html?module=bb&op=viewtopic&t=89436