GWT RPC SerializationException

Go To StackoverFlow.com

2

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?

2012-04-05 01:06
by Nick Heiner
Where is the definition of the object itself? Does it contain anything besides your fooMap - Travis Webb 2012-04-05 01:09
the object itself is Serializable, and works fine when fooMap is removed or is empty - Nick Heiner 2012-04-05 01:10
My inclination is to look at the GWT-serialization characteristics of the Map implementation you are using - stickfigure 2012-04-05 03:45
Try to manually create default constructor for Class FooImpl. It should solve your problem - hsestupin 2012-04-05 06:33


2

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.

2012-04-05 13:40
by jusio
Ads