I am trying to send an object across GWT RPC (GWT 2.4). The object includes an object which includes the following field:
@Serialized
private Map<Class<? extends Foo>, Foo> fooMap = ImmutableMap.of();
Foo is defined as:
public interface Foo extends Serializable {
}
When fooMap is empty, it works fine. When it is populated, the GWT RPC fails with a SerializationException. (The server is never hit.) The only type of Foo in fooMap is from this class:
public class FooImpl implements Foo {
private static final long serialVersionUID = 1L;
private long bar;
private float baz;
private int batz;
...
}
What am I doing wrong? FooImpl shouldn't be causing any problems. Every class has a no-arg constructor. I don't need getters and setters for every private field of every serialized object, right? Is Class<? extends Foo> a problem?
Serializable, and works fine when fooMap is removed or is empty - Nick Heiner 2012-04-05 01:10
Class<? extends Foo> is most likely a problem. As far as I know GWT simply don't know how to serialize-deserialize Class instance (it has code only for serializing normal objects, enums and arrays and there is no CustomFieldSerializer). So try to use classnames instead of Class instances.
fooMap- Travis Webb 2012-04-05 01:09