GWT RPC White List Magic
The reason I used the word magic is because that’s how it came across to me when I first came against this problem. This issue is more peculiar when one is using GXT and passing data back and forth between client and server using classes extending BaseModelData.
The general convention of writing your model classes is as following:
public class NameObj extends BaseModelData {
public String getFirstName() {
return this.get(“firstname”);
}
public void setFirstName (String name) {
this.set(“firstname”, name);
}
}
public class Person extends BaseModelData {
public NameObj getName() {
return this.get(“name”);
}
public void setName(NameObj name) {
this.set(“name”, name);
}
//so on
}
RPC Interface method
public Person getPersonList(args);
The above code points to one key convention especially when using GXT. We declare getter and setter for concrete types we want to deal with, but we need not want to declare data members for them as everything is being sent in the BaseModelData map.
Now the pitfall!! Since the NameObj was not declared as a data member of the Person class and only Person class is defined to be part of the RPC interface, GWT compiler would not add the NameObj class to RPC whitelist i.e. while serializing RPC response, GWT will most probably complain with the following error.
Caused by: com.google.gwt.user.client.rpc.SerializationException: Type 'com.myclassNameObj was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded.
A similar issue is reported on the following link as well.
http://osdir.com/ml/GoogleWebToolkit/2009-04/msg01287.html
Thus the GWT compiler smartly works on to find which are the essential classes which need to be serialized as it has the direct implication on amount of javascript compiler would generate and would be required to be downloaded on the browser. Since we were using GXT, we needed to set data in BaseModelData as GXT classes would work when data comes in the base model data map.
The current workaround which we came up with is a way to fake with GWT by declaring unused variables for the classes as following:
public class Person extends BaseModelData {
@SuppressWarnings(“unused”)
private NameObj _nameObj
public NameObj getName() {
return this.get(“name”);
}
public void setName(NameObj name) {
this.set(“name”, name);
}
//so on
}
This may not be the best way to deal with this issue, but as of now, I could not find any other approach. Anyone is welcome to suggest a better alternative.
I would publish another article soon on using dynamic Intenationalization with GWT by using a smarter way than writing a huge array. But that discussion merits a separate article.

You should be able to implement the IsSerializable interface to avoid that problem.
public class NameObj extends BaseModelData implements IsSerializable {
…
}