Serialisation pb when working with interface SET

4 views
Skip to first unread message

FCFem

unread,
Sep 21, 2006, 11:11:16 AM9/21/06
to Google Web Toolkit
hello,

I use Hibernate for the server part code. This is a client object code
(a data bean) :

public class Department implements IsSerializable {
private Long id;
private String code ;
private String name ;
private String manager ;
private Set users = new HashSet() ;
}

It seems that there are something wrong with the type SET for the
serialization, but I need it for Hibernate data mapping. Here is error
message that I get when I try to get the department data from the
server :

[WARN] Exception thrown into JavaScript
java.lang.RuntimeException: Checked exception thrown into JavaScript
(web mode behavior may differ)
at
com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:217)
at
com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:108)
at
org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
at
org.eclipse.swt.internal.ole.win32.IDispatch.Invoke(IDispatch.java:64)
at
org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:487)
at
org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:413)
at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNative(ModuleSpaceIE6.java:365)
at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNativeObject(ModuleSpaceIE6.java:233)
at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:103)
at com.aol.da.client.Builder_TypeSerializer.deserializeImpl(transient
source for com.aol.da.client.Builder_TypeSerializer:94)
Caused by: com.google.gwt.user.client.rpc.SerializationException:
org.hibernate.collection.PersistentSet/2078043698
at
com.aol.da.client.Builder_TypeSerializer.raiseSerializationException(transient
source for com.aol.da.client.Builder_TypeSerializer:416)
at
com.google.gwt.dev.shell.StaticJavaDispatch.callMethod(StaticJavaDispatch.java:45)
at
com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:127)
at
com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:199)
at
com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:108)
at
org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
at
org.eclipse.swt.internal.ole.win32.IDispatch.Invoke(IDispatch.java:64)
at
org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:487)
at
org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:413)
at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNative(ModuleSpaceIE6.java:365)

What is wrong ? Can you help me ?

Thanks a lot !

Jon Vaughan

unread,
Sep 21, 2006, 12:25:33 PM9/21/06
to Google Web Toolkit
Hi,

I've just tried and I can successfully return a HashSet (my interface
specifies it as a collection). I have seen a similar error when
returning an entry set from a Map, so that could be a potential reason,
or of course you may be returning the Hibernate implementation of the
Set, which might not work either.

Jon

Josh H

unread,
Sep 21, 2006, 5:10:55 PM9/21/06
to Google Web Toolkit
Jon is right. The problem is that you are returning an instance of
org.hibernate.collection.PersistentSet, which is not a serializable
class. Before returning from your RPC code, use the HashSet(Collection)
constructor in the java.util.HashSet class, so you can get an instance
of java.util.HashSet, which GWT will be able to serialize.

Josh

PS: When I use the term "serializable" and "serialize", I am referring
to GWT's serialization, a la the
com.google.gwt.user.client.rpc.IsSerializable interface, not
java.io.Serializable.

FCFem

unread,
Sep 22, 2006, 9:03:13 AM9/22/06
to Google Web Toolkit
Thanks a lot for your help ! But it doesn't work. It gives another
exception. This is the code modified :

public class Department implements IsSerializable {

private Long id;
private String code ;
private String name ;
private String manager ;

private java.util.Set users = new java.util.HashSet( new Vector())
;

public java.util.Set getUsers() {
return (java.util.HashSet)users;
}

public void setUsers(java.util.Set users) {
this.users = new java.util.HashSet(new Vector(users)) ;
}

Note that there are not yet the data is the table User. Can you show me
your code that works with HashSet ?

Here is the new exception :

[WARN] Exception thrown into JavaScript

java.lang.RuntimeException: JavaScript method
'@com.aol.da.client.Builder_TypeSerializer::deserializeImpl(Lcom/google/gwt/user/client/rpc/SerializationStreamReader;Lcom/google/gwt/user/client/rpc/SerializationStreamObjectDecoder;Ljava/lang/String;)'
threw an exception
at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNative(ModuleSpaceIE6.java:394)


at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNativeObject(ModuleSpaceIE6.java:233)
at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:103)
at com.aol.da.client.Builder_TypeSerializer.deserializeImpl(transient
source for com.aol.da.client.Builder_TypeSerializer:94)

at com.aol.da.client.Builder_TypeSerializer.deserialize(transient
source for com.aol.da.client.Builder_TypeSerializer:90)
at
com.google.gwt.user.client.rpc.ClientSerializationStream.readObject(ClientSerializationStream.java:337)
at
com.google.gwt.user.client.rpc.core.java.util.ArrayList_CustomFieldSerializer.deserialize(ArrayList_CustomFieldSerializer.java:49)


at
com.google.gwt.dev.shell.StaticJavaDispatch.callMethod(StaticJavaDispatch.java:45)
at
com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:127)
at
com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:199)

Caused by: java.lang.RuntimeException: JavaScript method
'@com.aol.da.client.Builder_TypeSerializer::deserializeImpl(Lcom/google/gwt/user/client/rpc/SerializationStreamReader;Lcom/google/gwt/user/client/rpc/SerializationStreamObjectDecoder;Ljava/lang/String;)'
threw an exception
at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNative(ModuleSpaceIE6.java:394)


at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNativeObject(ModuleSpaceIE6.java:233)
at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:103)
at com.aol.da.client.Builder_TypeSerializer.deserializeImpl(transient
source for com.aol.da.client.Builder_TypeSerializer:94)

at com.aol.da.client.Builder_TypeSerializer.deserialize(transient
source for com.aol.da.client.Builder_TypeSerializer:90)
at
com.google.gwt.user.client.rpc.ClientSerializationStream.readObject(ClientSerializationStream.java:337)
at
com.aol.da.client.beans.Department_FieldSerializer.deserialize(transient
source for com.aol.da.client.beans.Department_FieldSerializer:58)


at
com.google.gwt.dev.shell.StaticJavaDispatch.callMethod(StaticJavaDispatch.java:45)
at
com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:127)
at
com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:199)

Caused by: java.lang.RuntimeException: JavaScript method
'@com.google.gwt.user.client.rpc.ClientSerializationStream::extract()'
returned 'undefined'. This can happen either because of a missing
return statement, or explicitly returning a value of 'undefined' (e.g.
'return element[nonexistent property]')
at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNative(ModuleSpaceIE6.java:371)
at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNativeString(ModuleSpaceIE6.java:264)
at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeString(JavaScriptHost.java:119)
at
com.google.gwt.user.client.rpc.ClientSerializationStream.extract(ClientSerializationStream.java:124)
at
com.google.gwt.user.client.rpc.SerializationStream.readInt(SerializationStream.java:109)
at
com.google.gwt.user.client.rpc.core.java.util.HashSet_CustomFieldSerializer.deserialize(HashSet_CustomFieldSerializer.java:51)


at
com.google.gwt.dev.shell.StaticJavaDispatch.callMethod(StaticJavaDispatch.java:45)
at
com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:127)
at
com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:199)
at
com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:108)
at
org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)


Thanks !

Miguel Méndez

unread,
Oct 2, 2006, 10:30:45 AM10/2/06
to Google-We...@googlegroups.com
Which GWT version are you using?  There was a bug with HashSet deserialization in versions prior to GWT 1.1.10 that would cause this type of failure.

HTH,

On 9/22/06, FCFem <yihongg...@yahoo.fr> wrote:

Thanks a lot for your help ! But it doesn't work. It gives another
exception. This is the code modified :

public class Department implements IsSerializable {

        private Long id;
        private String code ;
        private String name ;
        private String manager ;

    private java.util.Set users = new java.util.HashSet( new Vector())
;

public java.util.Set getUsers() {
                return ( java.util.HashSet)users;
        }

        public void setUsers(java.util.Set users) {
                this.users = new java.util.HashSet(new Vector(users)) ;
        }

Note that there are not yet the data is the table User. Can you show me
your code that works with HashSet ?

Here is the new exception :

[WARN] Exception thrown into JavaScript
java.lang.RuntimeException: JavaScript method
'@com.aol.da.client.Builder_TypeSerializer::deserializeImpl (Lcom/google/gwt/user/client/rpc/SerializationStreamReader;Lcom/google/gwt/user/client/rpc/SerializationStreamObjectDecoder;Ljava/lang/String;)'
threw an exception
        at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNative (ModuleSpaceIE6.java:394)

        at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNativeObject(ModuleSpaceIE6.java:233)
        at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java :103)
        at com.aol.da.client.Builder_TypeSerializer.deserializeImpl(transient
source for com.aol.da.client.Builder_TypeSerializer:94)
        at com.aol.da.client.Builder_TypeSerializer.deserialize(transient
source for com.aol.da.client.Builder_TypeSerializer:90)
        at
com.google.gwt.user.client.rpc.ClientSerializationStream.readObject(ClientSerializationStream.java:337)
        at
com.google.gwt.user.client.rpc.core.java.util.ArrayList_CustomFieldSerializer.deserialize (ArrayList_CustomFieldSerializer.java:49)

        at
com.google.gwt.dev.shell.StaticJavaDispatch.callMethod(StaticJavaDispatch.java:45)
        at
com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java :127)
        at
com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:199)
Caused by: java.lang.RuntimeException: JavaScript method
'@com.aol.da.client.Builder_TypeSerializer::deserializeImpl(Lcom/google/gwt/user/client/rpc/SerializationStreamReader;Lcom/google/gwt/user/client/rpc/SerializationStreamObjectDecoder;Ljava/lang/String;)'
threw an exception
        at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNative(ModuleSpaceIE6.java:394)
        at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNativeObject(ModuleSpaceIE6.java:233)
        at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:103)
        at com.aol.da.client.Builder_TypeSerializer.deserializeImpl(transient
source for com.aol.da.client.Builder_TypeSerializer:94 )
        at com.aol.da.client.Builder_TypeSerializer.deserialize(transient
source for com.aol.da.client.Builder_TypeSerializer:90)
        at
com.google.gwt.user.client.rpc.ClientSerializationStream.readObject (ClientSerializationStream.java:337)

        at
com.aol.da.client.beans.Department_FieldSerializer.deserialize(transient
source for com.aol.da.client.beans.Department_FieldSerializer:58)
        at
com.google.gwt.dev.shell.StaticJavaDispatch.callMethod (StaticJavaDispatch.java:45)

        at
com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:127)
        at
com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:199)
Caused by: java.lang.RuntimeException: JavaScript method
'@com.google.gwt.user.client.rpc.ClientSerializationStream::extract()'
returned 'undefined'. This can happen either because of a missing
return statement, or explicitly returning a value of 'undefined' ( e.g.
'return element[nonexistent property]')
        at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNative(ModuleSpaceIE6.java:371)
        at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNativeString (ModuleSpaceIE6.java:264)

        at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeString(JavaScriptHost.java:119)
        at
com.google.gwt.user.client.rpc.ClientSerializationStream.extract(ClientSerializationStream.java :124)
        at
com.google.gwt.user.client.rpc.SerializationStream.readInt(SerializationStream.java:109)
        at
com.google.gwt.user.client.rpc.core.java.util.HashSet_CustomFieldSerializer.deserialize(HashSet_CustomFieldSerializer.java:51)
        at
com.google.gwt.dev.shell.StaticJavaDispatch.callMethod(StaticJavaDispatch.java:45)
        at
com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:127)
        at
com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke (IDispatchImpl.java:199)

        at
com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:108)
        at
org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)


Thanks !





--
Miguel
Reply all
Reply to author
Forward
0 new messages