Problem with custom serialization in GWT 2.0

102 views
Skip to first unread message

evgeniy

unread,
Jan 5, 2010, 12:11:55 PM1/5/10
to Google Web Toolkit
Hello.
I used GWT 1.6.4 and custom field serializers for transmitting
entities retrieved with help of hibernate. It was done for handling
Hibernate collections. For example:

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.

David

unread,
Jan 6, 2010, 3:33:32 AM1/6/10
to Google Web Toolkit
Hi,

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.

http://groups.google.com/group/google-web-toolkit-contributors/browse_thread/thread/e6c2f25322b83955/7267b66bab5de8fa#7267b66bab5de8fa

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

Reply all
Reply to author
Forward
0 new messages