在GWT应用程序中执行RPC时SerializationPolicy错误 [英] SerializationPolicy error when performing RPC from within GWT application

查看:116
本文介绍了在GWT应用程序中执行RPC时SerializationPolicy错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下异常:


com.google.gwt.user.client.rpc.SerializationException:输入'java .lang.Long'未包含在可由此SerializationPolicy序列化的类型集合中,或者其Class对象无法加载。出于安全考虑,使用GWT 2.1和内置的Jetty服务器,这种类型不会被序列化


。根据文档,这种类型是绝对可序列化的...我如何将它包含在SerializationPolicy中?

解决方案

需要include RPC服务中的多余方法将多个对象列入白名单。这是因为使用泛型,GWT无法确定哪个对象可能会序列化到某些泛型中。

我包含所有可能的类型需要(非)序列化为对象的成员( SerializableWhitelist )。我向RPC servlet对象添加了一个方法,如:

public SerializableWhitelist junk(SerializableWhitelist l){return null; }



值得注意的是,需要将白名单数据类型作为参数和返回类型,因为GWT显然保留了两个单独的序列化策略。

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?

解决方案

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.

这篇关于在GWT应用程序中执行RPC时SerializationPolicy错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆