public class Category_CustomFieldSerializer {
public static void serialize(SerializationStreamWriter writer,
Category instance) throws SerializationException {
writer.writeString(instance.getName());
writer.writeObject(instance.getOperation());
writer.writeObject(new LinkedList<CategoryValue>
(instance.getCategoryValues()));
}
public static void deserialize(SerializationStreamReader reader,
Category instance) throws SerializationException {
instance.setName(reader.readString());
instance.setOperation((OperationType) reader.readObject());
instance.setCategoryValues((List<CategoryValue>)
reader.readObject());
}
}
It was perfectly working. Recently I decided to try GWT 2.0. And
suddenly I started to receive
"com.google.gwt.user.client.rpc.SerializationException: Type
'org.hibernate.collection.PersistentBag'...". I tried to print debug
info from custom serializer and seems it never called.
Does support for custom serializers ended in GWT 2.0? Is there some
mechanism to solve this problem, except separate data transfer
objects?
Best regards, Evgeniy.
I noticed the same problem. I was first assuming that it was the app
server (which I migrated at the same time) and they fact that we put
our gwt-servlet.jar at ear level. But I was thinking last night that
custom serializers might just be completely broken in this release.
The reason why it fails is that they use the wrong classloader to
check for custom field serializers.
There are possible (temporary) solutions:
1) make sure that you modify the gwt-servlet.jar manifest to include
your jar that contains the custom field serializers)
2) update the gwt-servlet.jar to contain your custom field serializers
3) Make a small change to
com.google.gwt.user.server.rpc.impl.SerializabilityUtil
The method computeHasCustomFieldSerializer must use ClassLoader
classLoader = Thread.currentThread().getContextClassLoader(); instead
of Serializability.class.getClassLoader()
David