Cannot deserialized ArrayList object in GWT 2.3

1,090 views
Skip to first unread message

BM

unread,
Aug 9, 2011, 4:35:46 PM8/9/11
to Google Web Toolkit
I am getting this weird error "The response could not be deserialized"
during RPC call using GWT 2.3. I looked for similar threads on this
forum but their problem seems to be different than mine. Here is the
complete stack trace.

Also my ArrayList contains an Object which implements Serializable and
has properties with data types as String, Boolean and Date. All the
data types seems to have implemented Serializable interface. Please
help.


com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException: The
response could not be deserialized
at
com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:
221)
at
com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:
287)
at com.google.gwt.http.client.RequestBuilder
$1.onReadyStateChange(RequestBuilder.java:395)
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:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:
103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:
71)
at
com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:
167)
at
com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:
326)
at
com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:
207)
at
com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:
132)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:
561)
at
com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:
269)
at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:
91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:214)
at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:
103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:
71)
at
com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:
167)
at
com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:
281)
at
com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:
531)
at
com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:
352)
at java.lang.Thread.run(Thread.java:619)
Caused by: com.google.gwt.user.client.rpc.SerializationException:
java.util.ArrayList/3821976829
at
com.google.gwt.user.client.rpc.impl.SerializerBase.getTypeHandler(SerializerBase.java:
153)
at
com.google.gwt.user.client.rpc.impl.SerializerBase.instantiate(SerializerBase.java:
114)
at
com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:
111)
at
com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:
119)
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter
$ResponseReader$8.read(RequestCallbackAdapter.java:106)
at
com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:
214)
... 27 more

Ivan Pulleyn

unread,
Aug 9, 2011, 4:53:53 PM8/9/11
to google-we...@googlegroups.com
Is you object a plain-old Java object? Are you using any persistence engine on the server like Hibernate? Sometimes that can cause serialization issues, especially when something like Javassist manipulates byte code on the server.

Ivan...


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


Piotr Porzucek

unread,
Aug 10, 2011, 8:32:09 AM8/10/11
to Google Web Toolkit
I've got the same problem. I'm using POJO.
Any ideas...?

Regards,
Piotr
> > com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChanne lServer.java:
> > 281)
> >        at
>
> > com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChan nelServer.java:

Piotr Porzucek

unread,
Aug 10, 2011, 8:14:10 AM8/10/11
to Google Web Toolkit
I've got the same problem. I'm using POJO. Any ideas...?

On Aug 9, 10:53 pm, Ivan Pulleyn <ivan.pull...@gmail.com> wrote:
> > com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.jav a:
> > 167)
> >        at
>
> > com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingFo rReturn(BrowserChannelServer.java:
> > 326)
> >        at
>
> > com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChann elServer.java:
> > 207)
> >        at
> > com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:
> > 132)
> >        at
> > com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:
> > 561)
> >        at
> > com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:
> > 269)
> >        at
>
> > com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.j ava:
> > 91)
> >        at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
> >        at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:214)
> >        at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)
> >        at
>
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp l.java:
> > 25)
> >        at java.lang.reflect.Method.invoke(Method.java:597)
> >        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:
> > 103)
> >        at
> > com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:
> > 71)
> >        at
>
> > com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.jav a:
> > 167)
> >        at
>
> > com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChanne lServer.java:
> > 281)
> >        at
>
> > com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChan nelServer.java:
> > 531)
> >        at
>
> > com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java :
> > 352)
> >        at java.lang.Thread.run(Thread.java:619)
> > Caused by: com.google.gwt.user.client.rpc.SerializationException:
> > java.util.ArrayList/3821976829
> >        at
>
> > com.google.gwt.user.client.rpc.impl.SerializerBase.getTypeHandler(Serialize rBase.java:
> > 153)
> >        at
>
> > com.google.gwt.user.client.rpc.impl.SerializerBase.instantiate(SerializerBa se.java:
> > 114)
> >        at
>
> > com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deseria lize(ClientSerializationStreamReader.java:
> > 111)
> >        at
>
> > com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readO bject(AbstractSerializationStreamReader.java:

Alex Dobjanschi

unread,
Aug 10, 2011, 9:10:10 AM8/10/11
to google-we...@googlegroups.com
http://code.google.com/webtoolkit/doc/1.6/DevGuideServerCommunication.html#DevGuideSerializableTypes

If you have an ArrayList<A>, is A implementing Serializable? Also, the data types need to be gwt-translatable. This means you cannot (de)serialialize a domain object, that keeps references to Key(s), Rating, etc. And I think the referenced data types need to be in a source package inside your gwt.xml module
 <source path="client" />
 <source path="shared" />
 ...


Jens

unread,
Aug 10, 2011, 9:11:48 AM8/10/11
to google-we...@googlegroups.com
Does your custom object that is stored in the ArrayList contains a no-arg default constructor? Thats what I forget most of the times.

-- J.

Piotr Porzucek

unread,
Aug 10, 2011, 10:00:08 AM8/10/11
to Google Web Toolkit
All objects are serializable. The problem occurred after I had
upgraded to GWT 2.3.

Regards,
Piotr

Alex Dobjanschi

unread,
Aug 10, 2011, 10:38:18 AM8/10/11
to google-we...@googlegroups.com
You're really not showing us the code. 
Please follow the guidelines then, and check one by one.

BM

unread,
Aug 10, 2011, 10:51:34 AM8/10/11
to Google Web Toolkit
So I created two test methods to see if my POJO has a problem or not.
I am not even using my POJO but arraylist of String objects just to
make things simpler now.

1) Verified that my gwt.xml does have following.
<source path="client" />
<source path="shared" />

2) I created a simple Test RPC classes (MergeService,
MergeServiceAsync and MergeServiceImpl).

3) Implementation code inside MergeServiceImpl contains two methods.
public String testMethod()
{
return "Hello World";
}

public List<String> testMethod2() {
ArrayList<String> myList = new ArrayList<String>();
myList.add("hello1");
myList.add("world2");
return myList;
}


4) In the activity class I have following code:
clientFactory.getMergeServiceAsync().testMethod(new
AsyncCallback<String>() {

@Override
public void onSuccess(String result) {
Window.alert("testMethod - onSuccess");
}

@Override
public void onFailure(Throwable caught) {
caught.printStackTrace();
Window.alert("testMethod - onFailure");
}
});

clientFactory.getMergeServiceAsync().testMethod2(new
AsyncCallback<List<String>>() {

@Override
public void onSuccess(List<String> result) {
Window.alert("testMethod2 - onSuccess");
}

@Override
public void onFailure(Throwable caught) {
caught.printStackTrace();
Window.alert("testMethod2 - onFailure");
}
});

5) When I run the code, it executes Window.alert("testMethod -
onSuccess") and Window.alert("testMethod2 - onFailure").

So deserializing String object works but deserializing an ArrayList of
String objects (ArrayList does not even contain my POJO now but plain
simple String object) did not work in GWT 2.3

Is this a bug in GWT 2.3? What am I really missing here?

Jens

unread,
Aug 10, 2011, 11:21:11 AM8/10/11
to google-we...@googlegroups.com
I can't see why this shouldn't work. I am using a command pattern and I have some CommandResult classes that contain ArrayList<String> as fields and it works with GWT 2.3. I think if it would be a bug it would be recognized much earlier.

I think you maybe have outdated serialization information somewhere. Try to clean your project, delete GWT's generated javascript folder in the war folder and do a full rebuild / GWT compile. Also clean your browser cache. If this does not help you have to debug to see whats going on. Looking at the exception it seems like the server call has been successfully done but GWT fails to deserialize the server result. So it seems like a client side problem.

-- J.

Paul Robinson

unread,
Aug 10, 2011, 11:37:23 AM8/10/11
to google-we...@googlegroups.com
You should declare your service method to return "ArrayList<String>" and not "List<String>". Best practice for GWT is different from general Java best practice because using less-specific classes forces the GWT compiler to generate serialization code for every serializable subclass of List.

It may not fix your problem, but you should do it anyway.

Paul

BM

unread,
Aug 10, 2011, 12:09:25 PM8/10/11
to Google Web Toolkit
I cleaned all the files and folders inside Target folder (Using
Maven).
I removed all the files and folders newly created by GWT inside WAR
folder (Keeping CSS, WEB-INF, HTML files).

I did full rebuild and still has the same problem on simple plain
ArrayList of String objects as mentioned in my test case today I am
just using ArrayList of String objects.

Caused by: com.google.gwt.user.client.rpc.SerializationException:
java.util.ArrayList/3821976829
at
com.google.gwt.user.client.rpc.impl.SerializerBase.getTypeHandler(SerializerBase.java:
153)
at
com.google.gwt.user.client.rpc.impl.SerializerBase.instantiate(SerializerBase.java:
114)
at
com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:
111)
at
com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:
119)
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter
$ResponseReader$8.read(RequestCallbackAdapter.java:106)
at
com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:

I am thinking it has to do with some versioning of GWT serialization
classes but not sure how do I find that.

BM

unread,
Aug 10, 2011, 12:18:09 PM8/10/11
to Google Web Toolkit
Tried with HashSet<String> instead of List<String> and
ArrayList<String> and still did not work.


Caused by: com.google.gwt.user.client.rpc.SerializationException:
java.util.HashSet/1594477813
at
com.google.gwt.user.client.rpc.impl.SerializerBase.getTypeHandler(SerializerBase.java:
153)
at
com.google.gwt.user.client.rpc.impl.SerializerBase.instantiate(SerializerBase.java:
114)
at
com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:
111)
at
com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:
119)
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter
$ResponseReader$8.read(RequestCallbackAdapter.java:106)
at
com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:
214)
... 60 more

@Override
public HashSet<String> testMethod2() {
HashSet<String> myList = new HashSet<String>();
myList.add("hello1");
myList.add("world2");
return myList;
}

BM

unread,
Aug 10, 2011, 12:19:21 PM8/10/11
to Google Web Toolkit
Tried with hashset instead and did not work.

On Aug 10, 9:38 am, Alex Dobjanschi <alex.dobjans...@gmail.com> wrote:

Alex Dobjanschi

unread,
Aug 10, 2011, 12:21:39 PM8/10/11
to google-we...@googlegroups.com
BM, can you create an empty project and copy those files (service, service async, server impl, etc) & run it?

Juan Pablo Gardella

unread,
Aug 10, 2011, 12:30:32 PM8/10/11
to google-we...@googlegroups.com
Are you have the same version of gwt in web-inf and in the gwt eclipse plugin?  (if you use eclipse)

2011/8/10 BM <bhusha...@gmail.com>

BM

unread,
Aug 10, 2011, 12:34:35 PM8/10/11
to Google Web Toolkit
It works on an empty project.

So I compared my project with empty project. The difference is my
project uses Maven.

I realized gwt-servlet.jar was missing in my project. So when I copied
the gwt-servlet.jar in the lib folder created inside WEB-INF it
worked!

But the funny thing is my RPC call with String object was working fine
without gwt-servlet.jar

Thanks everyone on contributing and helping me. I am still surprise
how did gwt-servlet.jar gets deleted or may not be there in the first
place. And how did simple RPC worked before with String objects and
not working with ArrayList or HashSet objects.

We learn new things every day! Thanks again all of you for taking your
time to guide me here. I appreciate it!

On Aug 10, 11:21 am, Alex Dobjanschi <alex.dobjans...@gmail.com>
wrote:

POITTEVIN Raphael

unread,
Feb 23, 2012, 3:28:46 AM2/23/12
to Google-We...@googlegroups.com
BM <bhushan.madan@...> writes:

>
> It works on an empty project.
>
> So I compared my project with empty project. The difference is my
> project uses Maven.
>
> I realized gwt-servlet.jar was missing in my project. So when I copied
> the gwt-servlet.jar in the lib folder created inside WEB-INF it
> worked!
>
> But the funny thing is my RPC call with String object was working fine
> without gwt-servlet.jar
>
> Thanks everyone on contributing and helping me. I am still surprise
> how did gwt-servlet.jar gets deleted or may not be there in the first
> place. And how did simple RPC worked before with String objects and
> not working with ArrayList or HashSet objects.
>
> We learn new things every day! Thanks again all of you for taking your
> time to guide me here. I appreciate it!
>

> On Aug 10, 11:21 am, Alex Dobjanschi <alex.dobjans...@...>


> wrote:
> > BM, can you create an empty project and copy those files (service, service
> > async, server impl, etc) & run it?
>


Hi,

I was experimenting the exact same problem as you, using a simple service that
was returning a simple and serializable object that contained a List of
serializables objects.

I still didn't understand well what was wrong in my code. But looking back in my
pom.xml, I found that my version of gwt-servlet was 2.2.0 whereas my version of
gwt was 2.4.0 . I simply changed the gwt-servlet version to 2.4.0 and now it
works fine (didn't had to copy any jar anywhere).

Cheers,

Raphael POITTEVIN

Reply all
Reply to author
Forward
0 new messages