Friday, November 4, 2011

Re: Trouble figuring out why Serialization is breaking down

Your Attribute class has a non-final, non-transient field of type "Object". That will stop Attribute from being gwt-serializable, which in turn stops Node and XmlNode. Object is not supported for gwt serialization. It doesn't matter if you only ever happen to put gwt-serializable things in there, gwt won't accept it.

To answer your question though, one of the files output from the gwt compile is a *.rpc.log, and that gives detail on why things were or were not thought to be serializable.

Incidentally, you're better off with declaring class fields that are lists as ArrayList rather than List. Otherwise, gwt will have to generate serialization code for every implementation of List. GWT best practice in this regard is the opposite of general Java best practice.

Paul

On 04/11/11 14:58, laredotornado wrote:
> Hi, Yes, in all three classes I have a no-argument public constructor,
> like
>
> public XmlNode() { }
>
> Is there a way to get more specific information about why its
> failing? Thanks, - Dave
>
> On Nov 4, 9:37 am, Juan Pablo Gardella<gardellajuanpa...@gmail.com>
> wrote:
>> Do you have a public/package default constructor?
>>
>> 2011/11/4 Juan Pablo Gardella<gardellajuanpa...@gmail.com>
>>
>>
>>
>>
>>
>>
>>
>>> puff, ignore the last mail.
>>> 2011/11/4 Juan Pablo Gardella<gardellajuanpa...@gmail.com>
>>>> You don't have in classpath the sources
>>>> of com.cme.clearing.common.xml.XmlNode. This is the cause.
>>>> 2011/11/4 laredotornado<laredotorn...@zipmail.com>
>>>>> Hi,
>>>>> I'm trying to pass an object over RPC but the call is failing with a
>>>>> "com.google.gwt.user.client.rpc.SerializationException" exception.
>>>>> Complete stack trace is below. How do I figure out what field is
>>>>> causing the problem? The class and its member fields in question
>>>>> are ...
>>>>> public class XmlNode implements Serializable {
>>>>> private Node dataRoot;
>>>>> private List<XmlNode> parents = new ArrayList<XmlNode>();
>>>>> private List<XmlNode> children = new ArrayList<XmlNode>();
>>>>> ...
>>>>> public class Node implements Serializable {
>>>>> private long id;
>>>>> private short type;
>>>>> private String name;
>>>>> private String value;
>>>>> private List<Node> children;
>>>>> private Node parent;
>>>>> private Map<String, Attribute> attributes;
>>>>> ...
>>>>> public class Attribute implements Serializable {
>>>>> private String name;
>>>>> private Object value;
>>>>> private Node node;
>>>>> There are getters and setters for everything. How do I get GWT to
>>>>> tell me more about why Serialization is failing? - Dave
>>>>> ps - The error stack trace is
>>>>> com.google.gwt.user.client.rpc.SerializationException: Type
>>>>> 'com.cme.clearing.common.xml.XmlNode' was not included in the set of
>>>>> types which can be serialized by this SerializationPolicy or its Class
>>>>> object could not be loaded. For security purposes, this type will not
>>>>> be serialized.: instance = XmlNode
>>>>> at
>>>>> com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.seriali ze(ServerSerializationStreamWriter.java:
>>>>> 619)
>>>>> at
>>>>> com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.write Object(AbstractSerializationStreamWriter.java:
>>>>> 126)
>>>>> at
>>>>> com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter
>>>>> $ValueWriter$8.write(ServerSerializationStreamWriter.java:153)
>>>>> at
>>>>> com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.seriali zeValue(ServerSerializationStreamWriter.java:
>>>>> 539)
>>>>> at com.google.gwt.user.server.rpc.RPC.encodeResponse(RPC.java:616)
>>>>> at
>>>>> com.google.gwt.user.server.rpc.RPC.encodeResponseForSuccess(RPC.java:
>>>>> 474)
>>>>> at
>>>>> com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:
>>>>> 571)
>>>>> at
>>>>> com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServi ceServlet.java:
>>>>> 208)
>>>>> at
>>>>> com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServi ceServlet.java:
>>>>> 248)
>>>>> at
>>>>> com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(Abstract RemoteServiceServlet.java:
>>>>> 62)
>>>>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
>>>>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>>>>> at
>>>>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:
>>>>> 487)
>>>>> at
>>>>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:
>>>>> 362)
>>>>> at
>>>>> org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:
>>>>> 216)
>>>>> at
>>>>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:
>>>>> 181)
>>>>> at
>>>>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:
>>>>> 729)
>>>>> at
>>>>> org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:
>>>>> 405)
>>>>> at
>>>>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
>>>>> 152)
>>>>> at
>>>>> org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:
>>>>> 49)
>>>>> at
>>>>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
>>>>> 152)
>>>>> at org.mortbay.jetty.Server.handle(Server.java:324)
>>>>> at
>>>>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
>>>>> 505)
>>>>> at org.mortbay.jetty.HttpConnection
>>>>> $RequestHandler.content(HttpConnection.java:843)
>>>>> at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
>>>>> at
>>>>> org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
>>>>> at
>>>>> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
>>>>> at
>>>>> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:
>>>>> 395)
>>>>> at org.mortbay.thread.QueuedThreadPool
>>>>> $PoolThread.run(QueuedThreadPool.java:488)
>>>>> --
>>>>> 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-web-toolkit@googlegroups.com
>>>>> .
>>>>> To unsubscribe from this group, send email to
>>>>> google-web-toolkit+unsubscribe@googlegroups.com.
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/google-web-toolkit?hl=en.

--
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-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment