I have a simple POJO which has some attributes, one of them being an enum. This worked fine but when I changed the enum attribute to a List of enums GWT gives me a serialization exception "could not deserialize the response".
This works:
public class Report implements Serializable, Comparable<Report> {
private static final long serialVersionUID = 1L;
private long id;
//some more attributes, all serialize fine
private ReportCategory category; // the enumeration
public ReportSVO(){
}
//.. generated getters and setters
}
When I changed the private ReportCategory category;
to private List<ReportCategory> categories;
I got the (de)serialization exception.
Out of a hunch, I changed the enum to an inner class: (public enum ReportCategory{...}
to public class ReportCategory{
private Name categoryName;
public enum Name{...}}
) and like magic, it works.
This problem leads me to two questions:
- Is this a GWT bug? Or am I missing something?
- Is there a nicer way to solve this problem?
The enum itself should not be a problem as it was working before (and enums are serializable by default). Also, when I forgot a no-args constructor on other GWT classes or had a non-serializable attribute the serialization exception message was like this: "com.google.gwt.user.client.rpc.SerializationException: Type '...' was not included in the set of types which can be serialized by this SerializationPolicy.."
I am using GWT 2.4