Sat, 10 Nov 07
InvocationException using GWT RPC and custom objects.
If you are using GWT 1.4 and sending custom objects over the wire, and see an exception like this in your log files:
2007-11-09 11:06:13 Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type 'com.foo.common.data.User' was not assignable to 'com.google.gwt.user.client.rpc.IsSerializable'
and did not have a custom field serializer. For security purposes, this type will not be serialized.
at com.google.gwt.user.server.rpc.impl.LegacySerializationPolicy.validateSerialize(LegacySerializationPolicy.java:136)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:331)
at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:81)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:259)
at com.google.gwt.user.server.rpc.RPC.encodeResponse(RPC.java:574)
at com.google.gwt.user.server.rpc.RPC.encodeResponseForSuccess(RPC.java:442)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:530)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:265)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:187)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
You may be very interested in this release note from the 1.4.59 release:
This exception caused me a world of grief, first because I wasn’t seeing anything in standard out (it logged to a different file), then because I couldn’t find the source of LegacySerializationPolicy, then because I have the gwt source in one directory, but because of rewrites, it appears to be served from another directory. It manifests on the client side as an InvocationException with a fantasticly unhelpful error message.
The fix is simple: copy the serialization policy file to wherever the GWT files appear to be served from.
Technorati Tags: GWT RPC, doh!, always check all your log files
« FogBugz world tour, Boulder edition | Permalink | The ant jar task and duplicate files can cause bizarre behavior and missing/incorrect files when unzipping »
Matias said,
April 22, 2008 at 1:50 pm
Good post, save a lot of time for me.
David Vo said,
June 10, 2008 at 8:27 am
Could you tell me where precisely to put this file ?
moore said,
June 16, 2008 at 8:48 am
Hi David,
You need to put the RPC files in the path where the web server says they are being served from.
For example, if I have a bunch of gwt code that is deployed here:
/var/www/htdocs/mywebapp/code/gwt (where /var/www is your webroot)
but I have a rewrite rule that strips ‘/mywebapp/code’ from all requests, so that the gwt code is accessed via this url: http://www.mysite.com/gwt/…
then I need to have the rpc files in this directory:
/var/www/htdocs/gwt/
This is my experience with GWT 1.4.