SerializationException: type not included in serializable type set

前端 未结 6 1896
既然无缘
既然无缘 2021-01-07 17:14

In my Google Web Toolkit project, I got the following error:

com.google.gwt.user.client.rpc.SerializationException: Type ‘your.class.Type’ was not included in the se

6条回答
  •  一生所求
    2021-01-07 17:15

    GWT keeps track of a set of types which can be serialized and sent to the client. your.class.Type apparently was not on this list. Lists like this are stored in .gwt.rpc files. These lists are generated, so editing these lists is probably useless. How these lists are generated is a bit unclear, but you can try the following things:

    • Make sure your.class.Type implements java.io.Serializable
    • Make sure your.class.Type has a public no-args constructor
    • Make sure the members of your.class.Type do the same

    • Check if your program does not contain collections of a non-serializable type, e.g. ArrayList. If such a collection contains your.class.Type and is serialized, this error will occur.

    • Make your.class.Type implement IsSerializable. This marker interface was specifically meant for classes that should be sent to the client. This didn't work for me, but my class also implemented Serializable, so maybe both interfaces don't work well together.

    • Another option is to create a dummy class with your.class.Type as a member, and add a method to your RPC interface that gets and returns the dummy. This forces the GWT compiler to add the dummy class and its members to the serialization whitelist.

    • 提交回复
      热议问题