I first want to say that I know I have posted this problem on the EJB3 forum a couple of days ago, but because that forum is a lot less active than the hibernate forum, I got no response there, and the problem concerns hibernate completely I thought I would do no harm to post it here also.
Now for the problem :
This problem surfaced after moving to EJB3RC4-PFD.
I receive an exception (see below) on the client when loading a Entity with uninitialized relations. It seems that the client is trying to cast the attribute to a SerializableProxy (which seems reasonable for a lazy loaded relation) but receives a ClassCastException in the progress. This works fine when I initialize all my properties in the Session Bean. It also worked fine with EJB3.0RC3.
Has anything changed regarding the Entity class requirements? I couldn't find anything in migrating part on the wiki.
anyone has any idea ?
thanks a lot in advance!
Hibernate version:
The hibernate version that comes with JBoss EJB3.0RC4-PFD
Mapping documents:
Code:
@Entity
public class CommercieelContact extends BaseEntity {
private AankoopAfspraken aankoopAfspraken;
@OneToOne(cascade={CascadeType.ALL},fetch=FetchType.LAZY)
public AankoopAfspraken getAankoopAfspraken() {
return aankoopAfspraken;
}
}
Code:
@Entity
public class AankoopAfspraken extends BaseEntity {
}
Code:
@MappedSuperclass
public abstract class BaseEntity extends Model implements Serializable {
}
Full stack trace of any exception that occurs:Code:
[12:16:42,015] [ERROR] [SocketClientInvoker:274] - Got marshalling exception, exiting
java.lang.ClassCastException: cannot assign instance of org.hibernate.proxy.SerializableProxy to field be.profitplus.entities.contact.CommercieelContact.aankoopAfspraken of type be.profitplus.entities.contact.AankoopAfspraken in instance of be.profitplus.entities.contact.CommercieelContact
at java.io.ObjectStreamClass$FieldReflector.setObjFieldValues(ObjectStreamClass.java:1977)
at java.io.ObjectStreamClass.setObjFieldValues(ObjectStreamClass.java:1157)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1918)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
at java.util.ArrayList.readObject(ArrayList.java:592)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:919)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1813)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
at org.jboss.aop.joinpoint.InvocationResponse.readExternal(InvocationResponse.java:107)
at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1711)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObject(JavaSerializationManager.java:128)
at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:66)
at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:260)
at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:131)
at org.jboss.remoting.Client.invoke(Client.java:258)
at org.jboss.remoting.Client.invoke(Client.java:221)
at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:55)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:55)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:65)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.ejb3.stateful.StatefulRemoteProxy.invoke(StatefulRemoteProxy.java:133)
at $Proxy3.getCommercieelContacten(Unknown Source)
at be.profitplus.client.businessdelegates.CommercialContactManagerBD.getContacts(CommercialContactManagerBD.java:72)
at be.profitplus.client.gui.components.datasource.CommercialContactDataSource.getCollection(CommercialContactDataSource.java:13)
at be.profitplus.client.gui.components.prototypes.PPSPPPrototype.objectSearched(PPSPPPrototype.java:205)
at be.profitplus.client.gui.components.prototypes.PPSPPPrototype$1.actionPerformed(PPSPPPrototype.java:102)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:231)
at java.awt.Component.processMouseEvent(Component.java:5488)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
at java.awt.Component.processEvent(Component.java:5253)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1774)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:153)
at java.awt.Dialog$1.run(Dialog.java:515)
at java.awt.Dialog.show(Dialog.java:536)
at java.awt.Component.show(Component.java:1300)
at java.awt.Component.setVisible(Component.java:1253)
at be.profitplus.client.gui.components.prototypes.PPManagementPrototype.openSearchWindow(PPManagementPrototype.java:321)
at be.profitplus.client.gui.components.prototypes.PPManagementPrototype.processCode(PPManagementPrototype.java:273)
at be.profitplus.client.gui.components.prototypes.PPManagementPrototype$1.keyPressed(PPManagementPrototype.java:107)
at java.awt.Component.processKeyEvent(Component.java:5446)
at javax.swing.JComponent.processKeyEvent(JComponent.java:2713)
at java.awt.Component.processEvent(Component.java:5265)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1810)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:672)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:920)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:798)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:636)
at java.awt.Component.dispatchEventImpl(Component.java:3841)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Window.dispatchEventImpl(Window.java:1774)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Exception occurred during event dispatching:
java.lang.reflect.UndeclaredThrowableException
at $Proxy3.getCommercieelContacten(Unknown Source)
at be.profitplus.client.businessdelegates.CommercialContactManagerBD.getContacts(CommercialContactManagerBD.java:72)
at be.profitplus.client.gui.components.datasource.CommercialContactDataSource.getCollection(CommercialContactDataSource.java:13)
at be.profitplus.client.gui.components.prototypes.PPSPPPrototype.objectSearched(PPSPPPrototype.java:205)
at be.profitplus.client.gui.components.prototypes.PPSPPPrototype$1.actionPerformed(PPSPPPrototype.java:102)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:231)
at java.awt.Component.processMouseEvent(Component.java:5488)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
at java.awt.Component.processEvent(Component.java:5253)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1774)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:153)
at java.awt.Dialog$1.run(Dialog.java:515)
at java.awt.Dialog.show(Dialog.java:536)
at java.awt.Component.show(Component.java:1300)
at java.awt.Component.setVisible(Component.java:1253)
at be.profitplus.client.gui.components.prototypes.PPManagementPrototype.openSearchWindow(PPManagementPrototype.java:321)
at be.profitplus.client.gui.components.prototypes.PPManagementPrototype.processCode(PPManagementPrototype.java:273)
at be.profitplus.client.gui.components.prototypes.PPManagementPrototype$1.keyPressed(PPManagementPrototype.java:107)
at java.awt.Component.processKeyEvent(Component.java:5446)
at javax.swing.JComponent.processKeyEvent(JComponent.java:2713)
at java.awt.Component.processEvent(Component.java:5265)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1810)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:672)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:920)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:798)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:636)
at java.awt.Component.dispatchEventImpl(Component.java:3841)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Window.dispatchEventImpl(Window.java:1774)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Caused by: java.rmi.MarshalException: Failed to communicate. Problem during marshalling/unmarshalling; nested exception is:
java.lang.ClassCastException: cannot assign instance of org.hibernate.proxy.SerializableProxy to field be.profitplus.entities.contact.CommercieelContact.aankoopAfspraken of type be.profitplus.entities.contact.AankoopAfspraken in instance of be.profitplus.entities.contact.CommercieelContact
at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:287)
at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:131)
at org.jboss.remoting.Client.invoke(Client.java:258)
at org.jboss.remoting.Client.invoke(Client.java:221)
at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:55)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:55)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:65)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
at org.jboss.ejb3.stateful.StatefulRemoteProxy.invoke(StatefulRemoteProxy.java:133)
... 57 more
Caused by: java.lang.ClassCastException: cannot assign instance of org.hibernate.proxy.SerializableProxy to field be.profitplus.entities.contact.CommercieelContact.aankoopAfspraken of type be.profitplus.entities.contact.AankoopAfspraken in instance of be.profitplus.entities.contact.CommercieelContact
at java.io.ObjectStreamClass$FieldReflector.setObjFieldValues(ObjectStreamClass.java:1977)
at java.io.ObjectStreamClass.setObjFieldValues(ObjectStreamClass.java:1157)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1918)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
at java.util.ArrayList.readObject(ArrayList.java:592)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:919)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1813)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
at org.jboss.aop.joinpoint.InvocationResponse.readExternal(InvocationResponse.java:107)
at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1711)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObject(JavaSerializationManager.java:128)
at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:66)
at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:260)
... 69 more
Name and version of the database you are using:
PostgreSQL 8.0.5