[jboss-user] [EJB 3.0] - ClassCastException deserializing EJB3 Entity Bean

justinmiller do-not-reply at jboss.com
Thu Sep 14 00:54:34 EDT 2006


Hey all,

     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.

    Justin

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3971465#3971465

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3971465



More information about the jboss-user mailing list