簡體   English   中英

為什么此類無法序列化?

[英]Why this class not serializable?

我有錯誤:

com.google.gwt.user.client.rpc.SerializationException: Type 'ru.xxx.empeditor.client.Dept$$EnhancerByCGLIB$$2f6af516' 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 = ru.xxx.empeditor.client.Dept@e53d4e

為什么此類無法序列化?

package ru.xxx.empeditor.client;

import java.util.HashSet;
import java.util.Set;

import com.google.gwt.user.client.rpc.IsSerializable;

/**
 * Dept generated by hbm2java
 */
public class Dept implements IsSerializable {

    private byte deptno;
    private String dname;
    private String loc;
    private Set<Emp> emps = new HashSet<Emp>(0);

    public Dept() {
    }

    public Dept(byte deptno) {
        this.deptno = deptno;
    }

    public Dept(byte deptno, String dname, String loc, Set<Emp> emps) {
        this.deptno = deptno;
        this.dname = dname;
        this.loc = loc;
        this.emps = emps;
    }

    public byte getDeptno() {
        return this.deptno;
    }

    public void setDeptno(byte deptno) {
        this.deptno = deptno;
    }

    public String getDname() {
        return this.dname;
    }

    public void setDname(String dname) {
        this.dname = dname;
    }

    public String getLoc() {
        return this.loc;
    }

    public void setLoc(String loc) {
        this.loc = loc;
    }

    public Set<Emp> getEmps() {
        return this.emps;
    }

    public void setEmps(Set<Emp> emps) {
        this.emps = emps;
    }

}

檢查Emp類是否可序列化。

另一個潛在的問題(因為您正在使用Hibernate-注意到自動生成的注釋)可能是由於代理修改了您的bean的字節碼,導致GWT無法序列化它。 如此處所述-http: //code.google.com/webtoolkit/articles/using_gwt_with_hibernate.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM