{"id":444,"date":"2007-11-10T16:02:57","date_gmt":"2007-11-10T22:02:57","guid":{"rendered":"http:\/\/www.mooreds.com\/wordpress\/archives\/000444"},"modified":"2011-03-06T12:10:23","modified_gmt":"2011-03-06T18:10:23","slug":"invocationexception-using-gwt-rpc-and-custom-objects","status":"publish","type":"post","link":"https:\/\/www.mooreds.com\/wordpress\/archives\/444","title":{"rendered":"InvocationException using GWT RPC and custom objects"},"content":{"rendered":"<p>If you are using GWT 1.4 and sending custom objects over the wire, and see an exception like this in your log files:<\/p>\n<div>\n<pre><code>\r\n2007-11-09 11:06:13 Exception while dispatching incoming RPC call\r\ncom.google.gwt.user.client.rpc.SerializationException: Type 'com.foo.common.data.User' was not assignable to 'com.google.gwt.user.client.rpc.IsSerializable'\r\nand did not have a custom field serializer.  For security purposes, this type will not be serialized.\r\nat com.google.gwt.user.server.rpc.impl.LegacySerializationPolicy.validateSerialize(LegacySerializationPolicy.java:136)\r\nat com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:331)\r\nat com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:81)\r\nat com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:259)\r\nat com.google.gwt.user.server.rpc.RPC.encodeResponse(RPC.java:574)\r\nat com.google.gwt.user.server.rpc.RPC.encodeResponseForSuccess(RPC.java:442)\r\nat com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:530)\r\nat com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:265)\r\nat com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:187)\r\nat javax.servlet.http.HttpServlet.service(HttpServlet.java:760)\r\n<\/code><\/pre>\n<\/div>\n<p>You may be very interested in this release note from the 1.4.59 release:<\/p>\n<p><a href=\"http:\/\/code.google.com\/webtoolkit\/release-notes.html#Release_Notes_1_4_59\">RPC now generates a serialization policy file during compilation. The serialization policy file contains a whitelist of allowed types which may be serialized. Its name is a strong hash name followed by .gwt.rpc. This file must be deployed to your web server as a public resource, accessible from a RemoteServiceServlet  via ServletContext.getResource(). If it is not deployed properly, RPC will run in 1.3.3 compatibility mode and refuse to serialize types implementing Serializable.<\/a> <strong>Updated 3\/6\/2011 to correct link location.<\/strong><\/p>\n<p>This exception caused me a world of grief, first because I wasn&#8217;t seeing anything in standard out (it logged to a different file), then because I couldn&#8217;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 <a href=\"http:\/\/google-web-toolkit.googlecode.com\/svn\/javadoc\/1.4\/com\/google\/gwt\/user\/client\/rpc\/InvocationException.html\">InvocationException<\/a> with a fantasticly unhelpful error message.<\/p>\n<p>The fix is simple: copy the serialization policy file to wherever the GWT files appear to be served from.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-444","post","type-post","status-publish","format-standard","hentry","category-gwt"],"_links":{"self":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/444","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/comments?post=444"}],"version-history":[{"count":3,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/444\/revisions"}],"predecessor-version":[{"id":706,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/444\/revisions\/706"}],"wp:attachment":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/media?parent=444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/categories?post=444"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/tags?post=444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}