GWT:类型'java.util.HashMap $ KeySet'的com.google.gwt.user.client.rpc.SerializationException

时间:2012-12-20 04:07:34

标签: gwt

我收到了HashSet的com.google.gwt.user.client.rpc.SerializationException异常。
最初我认为不支持HashSet of Long 但是https://developers.google.com/web-toolkit/doc/latest/RefJreEmulation包含这两个。

会出现什么问题?

我在这里发布服务方法:

public Set<Long> getNamesFromIDs(Set<Long> ids) {
    return manager.getNamesFromIDs(ids);
}

这里,manager是对库中包含的Manager类的引用。 我也在发布经理方法:

public Set<Long> getNamesFromIDs(Set<Long> styleIds) {
    List<Long> listIDs = new ArrayList<Long>(styleIds);
    Map<Long, Discount> personMap = personDAO.getStyleIdToDiscountMap(listIDs, 0);
    return personMap.keySet();
}

详细例外消息:

com.google.gwt.user.client.rpc.SerializationException: Type 'java.util.HashMap$KeySet'   
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.: instance = [30002, 30001]

1 个答案:

答案 0 :(得分:1)

enter image description here

java.util中的上述类由自定义字段序列化程序序列化。

GWT不支持

序列化。它没有实现Serializable接口(因此它在java世界中也不可序列化)