Serialization issue

2 views
Skip to first unread message

mikee

unread,
Jul 3, 2006, 3:52:46 AM7/3/06
to Google Web Toolkit
I met a question very confusing and I have searched for similar issue
others had posted in the forum, but there's no approach clearly .
I have a custom class in the client implements the IsSerializable
and it has a List type member ,the List contains a custome class that
has also implemented the IsSerializable , I need to call rpc from
server to fetch data to client. but it throw exception following:(My
code is after the exception)

Could any one tell me how to handle the issue? I'll appreciate for any
reply, thanks a lot!
java.lang.RuntimeException: JavaScript method
'@com.telenav.ac.web.client.ACRemoteService_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.telenav.ac.web.client.ACRemoteService_TypeSerializer.deserializeImpl(transient
source for com.telenav.ac.web.client.ACRemoteService_TypeSerializer:69)
at
com.telenav.ac.web.client.ACRemoteService_TypeSerializer.deserialize(transient
source for com.telenav.ac.web.client.ACRemoteService_TypeSerializer:65)
at
com.google.gwt.user.client.rpc.ClientSerializationStream.readObject(ClientSerializationStream.java:337)
at
com.telenav.ac.web.client.ACRemoteService_Proxy$1.onCompletionImpl(transient
source for com.telenav.ac.web.client.ACRemoteService_Proxy:61)
at
com.telenav.ac.web.client.ACRemoteService_Proxy$1.onCompletionAndCatch(transient
source for com.telenav.ac.web.client.ACRemoteService_Proxy:48)
at
com.telenav.ac.web.client.ACRemoteService_Proxy$1.onCompletion(transient
source for com.telenav.ac.web.client.ACRemoteService_Proxy:42)
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
com.google.gwt.dev.shell.InstanceJavaDispatch.callMethod(InstanceJavaDispatch.java:40)
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.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1656)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2711)
at com.google.gwt.dev.GWTShell.pumpEventLoop(GWTShell.java:491)
at com.google.gwt.dev.GWTShell.run(GWTShell.java:459)
at com.google.gwt.dev.GWTShell.main(GWTShell.java:208)
Caused by: java.lang.RuntimeException: JavaScript method
'@com.telenav.ac.web.client.ACRemoteService_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.telenav.ac.web.client.ACRemoteService_TypeSerializer.deserializeImpl(transient
source for com.telenav.ac.web.client.ACRemoteService_TypeSerializer:69)
at
com.telenav.ac.web.client.ACRemoteService_TypeSerializer.deserialize(transient
source for com.telenav.ac.web.client.ACRemoteService_TypeSerializer:65)
at
com.google.gwt.user.client.rpc.ClientSerializationStream.readObject(ClientSerializationStream.java:337)
at
com.telenav.ac.web.client.GWTResponse_FieldSerializer.deserialize(transient
source for com.telenav.ac.web.client.GWTResponse_FieldSerializer:27)
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
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.COM.VtblCall(Native Method)
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)
... 23 more
Caused by: java.lang.RuntimeException: JavaScript method
'@com.telenav.ac.web.client.ACRemoteService_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.telenav.ac.web.client.ACRemoteService_TypeSerializer.deserializeImpl(transient
source for com.telenav.ac.web.client.ACRemoteService_TypeSerializer:69)
at
com.telenav.ac.web.client.ACRemoteService_TypeSerializer.deserialize(transient
source for com.telenav.ac.web.client.ACRemoteService_TypeSerializer:65)
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 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
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.COM.VtblCall(Native Method)
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)
... 43 more
Caused by: java.lang.RuntimeException: JavaScript method
'@com.telenav.ac.web.client.ACRemoteService_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.telenav.ac.web.client.ACRemoteService_TypeSerializer.deserializeImpl(transient
source for com.telenav.ac.web.client.ACRemoteService_TypeSerializer:69)
at
com.telenav.ac.web.client.ACRemoteService_TypeSerializer.deserialize(transient
source for com.telenav.ac.web.client.ACRemoteService_TypeSerializer:65)
at
com.google.gwt.user.client.rpc.ClientSerializationStream.readObject(ClientSerializationStream.java:337)
at
com.telenav.ac.web.client.StreetItem_FieldSerializer.deserialize(transient
source for com.telenav.ac.web.client.StreetItem_FieldSerializer:38)
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
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.COM.VtblCall(Native Method)
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)
... 63 more
Caused by: 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.COM.VtblCall(Native Method)
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)
... 83 more
Caused by: com.google.gwt.user.client.rpc.SerializationException:
java.util.Arrays$ArrayList/3899573920
at
com.telenav.ac.web.client.ACRemoteService_TypeSerializer.raiseSerializationException(transient
source for
com.telenav.ac.web.client.ACRemoteService_TypeSerializer:331)
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
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)
... 90 more


public class StreetItem implements IsSerializable {
private String streetName = null;

private String state = null;

/**
*
*
* @gwt.typeArgs <com.telenav.ac.web.client.data.ZipcodeBlocksData>
*/
private List zipcodesData = null;
..........
}
public class ZipcodeBlocksData implements IsSerializable {
private String zipcode;

/**
*
* @gwt.typeArgs <com.telenav.ac.web.client.data.BlockData>
*/
private List blocks;

private String cityName;
.....
}
public class BlockData extends ACAdminData implements IsSerializable{
there's some primitive type fields(String int...).
}
The 3 classes above are all in the client.

In the server side, I call the rpc method searchStreet() from client
public GWTResponse searchStreet(String streetInput, String stateInput,
String cityInput) {
String[] streetsMatched = { "2280 Myers St, Oroville, CA" };
StreetItem[] streetItems = new StreetItem[streetsMatched.length];

for (int i = 0; i < streetItems.length; i++) {
streetItems[i] = new StreetItem(streetsMatched[i]);
streetItems[i].setState("CA");
//The following setZipcodesData code will cause
the exception above. because when I comment the line bellow , I will
get data from server except the zipcodes data list.
streetItems[i].setZipcodesData(getFakeData(streetItems[i]));
}
private List getFakeData(StreetItem street) {
// String[] zipcodes = new String[10];
ZipcodeBlocksData[] datas = new ZipcodeBlocksData[20];

java.util.Random random = new java.util.Random();
for (int i = 0; i < datas.length; i++) {
datas[i] = new ZipcodeBlocksData();
datas[i].setZipcode(10000 + random.nextInt(100) + "");
datas[i].setCityName("Newyork");
List blocks = new ArrayList();
int block_num = random.nextInt(25) + 1;
for (int j = 0; j < block_num; j++) {
int startDoornum = random.nextInt(10);// because in the server side
,so It user java.util.Random class not the gwt Random class
int endDoornum = random.nextInt(50) + startDoornum;
if ((startDoornum & 0X1) == 0) {
if ((endDoornum & 0X1) != 0) {
endDoornum++;
}
} else {
if ((endDoornum & 0X1) == 0) {
endDoornum++;
}
}
int startLat = random.nextInt(10000);
int startLon = random.nextInt(10000);
int latDiff = random.nextInt(1000);
int lonDiff = random.nextInt(1000);
int udb = random.nextInt(3);
BlockData blockData = new BlockData(startDoornum, endDoornum,
startLat, startLon, latDiff, lonDiff, udb);
blockData.setZipcode(datas[i].getZipcode());
blockData.setCityName(datas[i].getCityName());
blockData.setStreetName(street.getStreetName());
blockData.setState(street.getState());
blocks.add(blockData);
}
datas[i].setBlocks(blocks);
}
return Arrays.asList(datas);

}
.......
}

georgeuoa

unread,
Jul 3, 2006, 5:47:21 AM7/3/06
to Google Web Toolkit
I believe this to be a bug, we've reported this (at least) twice:

http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/1b29be75d1b47ed/879c8438d50072bc?q=georgeuoa&rnum=7#879c8438d50072bc
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/b069f515ae967fd4/153a6d019d998fd2?q=georgeuoa&rnum=5#153a6d019d998fd2

The problem seems to be with multiple references occur, one 'normal'
reference and one from inside a List to the same object. Unfortunately
I know of no work around.

mikee

unread,
Jul 3, 2006, 6:16:42 AM7/3/06
to Google Web Toolkit
georgeuoa ,Thank you very much! :)
I want to try json to handle it.....but are there any examples about
using json in gwt? The gwt json example project seems to just
unmarshall the json file to java objects, and how to marshall the java
objects to jsonobject and how to send the jsonobject from the server to
client?
Thanks again!

aprunicki

unread,
Jul 4, 2006, 12:55:42 PM7/4/06
to Google Web Toolkit

I have encountered this issue too. The work-around I've used is to
basically "clone" the object. I have a copy method on virtually all my
objects that will copy the object. The code is marked with todos so
the work-around can be removed when the serialization problem is solved.

Reply all
Reply to author
Forward
0 new messages