I'm getting the following exception:
com.google.gwt.user.client.rpc.SerializationException: Type 'java.lang.Long' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized
using GWT 2.1 and the built in Jetty server. According to the docs, this type is definitely serializable... How can I include it in the SerializationPolicy?
Here's the link that should resolve problem: http://developerlife.com/tutorials/?p=131
A user defined class is serializable if:
- the class is assignable to IsSerializable or java.io.Serializable, either because it implements one of these interfaces, or because it is derived from a superclass that implements one of these interfaces.
- all the class’s non-final, non-transient instance fields are serializable
- the class has a public default (zero argument) constructor
Needed include a superfluous method in the RPC service that "whitelists" a number of objects. This arises because of the use of generics, GWT is unable to necessarily determine which object I may be serializing to include within some generic.
I included all of the types that may need to be (un)serialized as members of an object (SerializableWhitelist
). I added a method to the RPC servlet object like:
public SerializableWhitelist junk(SerializableWhitelist l) { return null; }
It's worth noting that you need to include the whitelist datatypes as both an argument and as the return type, as GWT apparently maintains two separate serialization policies.
Try deleting the *.gwt.rpc files in your war/app directory, clean and rebuild.
One thing to note: you should avoid long or Long if possible because they are
emulated on GWT (because there is no native Javascript long) and very
slow. Use int instead where ever you can.
FYI I've raised this as a GWT bug: http://code.google.com/p/google-web-toolkit/issues/detail?id=5811
We'll see what they say.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With