Sunday, September 14, 2014

GWT 2.2.0 does not serialize/deserialize basic Java types if not referenced explicitly

Hi GWT experts,
  I had a problem with the GWT-RPC on 2.2.0 and above.

  I have a generic service interface which serves as multiple RPC
requests depending on the value of event parameter:

    @RemoteServiceRelativePath("Service")
    public interface Service extends RemoteService {
        EventResult execute(String event, Map<String, Object> eventData)
                throws ServiceException;
    }

The details of request are passed as Map with String key and the value (the eventData)
can be String, Integer, Double and Date (java.util.Date precisely).
This works well on GWT 1.6.4. But when I try to upgrade to 2.2.0 (for
better dev mode tool), it complains that:

    Type 'java.util.Date' was not included in the set of types which can
be deserialized by this SerializationPolicy or its Class object could
not be loadded. For security purposes, this will not be deserialized.

I came across an SO post on a workaround to add the problematic type
explicitly to a dummy method. For instance to get past the java.util.Date
issue, you modify the above interface like:

    @RemoteServiceRelativePath("Service")
    public interface Service extends RemoteService {
        EventResult execute(String event, Map<String, Object> eventData)
                throws ServiceException;

        void dummy(Date date);
    }

Since the GWT 1.6.4 serialize/deserialize the basic Java types
correctly, I'm wondering if there is a better way to avoid messing up
the service interface. For instance, add some special configuration in
the module xml file to instruct the RPC policy generator always allow
serialization/deserialization of basic Java types.

Thank you very much!

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment