GWT – RPC serialization problem

Type ‘some.type.you.are.sure.is.serializable’ was not included in the set of types that can be serialized by this SerializationPolicy. For security purposes, this type will not be serialized.

One of the most irritating problems that you will probably (sooner or later) have to deal with is GWT serialization policy (or serialization white list). Luckily there are at least 2 ways to work around this issue. Please read GWT documentation and this FAQ first!

If GWT still fails to auto-detect your DTOs or other “go through the wire” objects serialization:

1. Mark your “controversial” objects with com.google.gwt.user.client.rpc.IsSerializable interface This can be a little “ugly” if you want to keep your DTOs clean, without GWT related dependencies… but you can still hack it with
2. Define a new Dummy class with member fields of all types you want to include in serialization. Then add a method to your RPC interface:
Dummy dummy(Dummy d); Add simple implementation:
Dummy dummy(Dummy d) { return d; } And deal with async interface:
void dummy(Dummy d, AsyncCallback callback); From now on the GWT compiler will have no problems with what is or what is not compatible with SerializationPolicy (credits for second solution to Andrej)

You May Also Like

Loops performance in Groovy

IntroductionIn the 2018 Advent of Code challenged I solved all the puzzles in Groovy. It is pretty obvious, that choosing good data structure is the most important to obtain performant solution. However, the way we iterate over those structures is also...