Home > Uncategorized > GWT: Not enough methods, expecting 3 saw 2

GWT: Not enough methods, expecting 3 saw 2

So, from time to time I am getting this error in GWT: “Not enough methods, expecting 3 saw 2″ in relation to Serialization, and I have finally figured out what it means. Basically, when GWT sees a Async service, it will generate a TypeSerializer to serialize and deserialize objects accessible from the service. This error occurs client side when a type doesn’t have it’s serializer registered in the TypeSerializer.

For our case, we have created an AnnotationProcessor for the bean annotation ConstructorProperties, we put this on the constructor for our classes. This will result in a custom serializer being constructed, so we can have final fields in the serialized objects, and just 1 constructor. The problem is when we use writeObject in these serializers. When the normal serialization generator visits a class with an interface field, it will discover all subclasses off that interface, and create a serializer for each. But, since I use a custom serializer, GWT will not discover any subtypes of an interface. So when I use the general writeObject, GWT will not be aware that it needs to register serializers of all subtypes of a certain interface.

The workaround in my case, was to rewrite the class so that GWT could create a custom serializer, which caused the proper fields to get registered. It still used my custom serializer to serialize objects, but now it also discovered that it needed to register the custom serializers for each type.

Categories: Uncategorized Tags:
  1. No comments yet.
  1. No trackbacks yet.