SerializationPolicy error when performing RPC from within GWT application

后端 未结 10 2005
醉梦人生
醉梦人生 2020-12-14 01:59

I\'m getting the following exception:

com.google.gwt.user.client.rpc.SerializationException: Type \'java.lang.Long\' was not included in the set of ty

相关标签:
10条回答
  • 2020-12-14 02:40

    Make sure that the class is in shared folder. This is what I was Missing.

    0 讨论(0)
  • 2020-12-14 02:46

    Here's the link that should resolve problem: http://developerlife.com/tutorials/?p=131

    A user defined class is serializable if:

    1. 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.
    2. all the class’s non-final, non-transient instance fields are serializable
    3. the class has a public default (zero argument) constructor
    0 讨论(0)
  • 2020-12-14 02:52

    The problem can also be because the code on your local machine on which you are running hosted mode is not the same as the one on the external server you are connecting to via RPC. So in my case i was missing a git pull on my local machine to match what was deployed on the external server. The changes were minimal, just a new property in one of the classes that were included in the gwt.rpc, but this was already sufficient that the gwt.rpc md5 filenames were different and thus the above mentioned error occurred.

    0 讨论(0)
  • 2020-12-14 02:53

    Another FWIW: I believe I cleared up a similar problem in an enum class by changing the access modifier of the single, one argument constructor from default (no modifier) to 'private'. In any event, doing that didn't break it because it's working that way now.

    0 讨论(0)
  • 2020-12-14 02:54

    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.

    0 讨论(0)
  • 2020-12-14 02:57

    I faced this error and got stuck for 1 day completely. Then I came to across following quick solution:

    Make sure your DTOs or Entities classes following the serializable interface rules. Its the the only thing you need to do because rest of the issues will be with your build creation. So if you are using maven then make sure do clean build and clear all browser cache. I resolved my issues with this. I hope it will help. Thanks!

    0 讨论(0)
提交回复
热议问题