有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java GWT错误:无法反序列化响应

我已经开发了几个GWT Web应用程序。最新的一个是另一个的一点修改。除了最新的一个,所有的都很好用。例外情况是:

The response could not be deserialized

我正在使用Hibernate和Hibernate与GWT之间的数据传输对象。每个DTO都实现java。木卫一。可序列化接口。正如我之前所说的,在其他应用程序中工作良好。有人能帮我解决这个错误吗?我不知道原因是什么

我的Hibernate对象代码是:

public List<AttributeDTO> getAttributes(){
    String sql = "from Attribute where (select max(tDate) from Attribute)-tDate < '0 days 00:05'";
    List<Attribute> attributes = new ArrayList<Attribute>(DatabaseManager.createQuery(sql));
    List<AttributeDTO> attributeDTOs = new ArrayList<AttributeDTO>(attributes != null ? attributes.size() : 0);
    if (attributes != null) {
        for (Attribute attribute : attributes) {
            String date = format.format(attribute.gettDate());
            attributeDTOs.add(new AttributeDTO(attribute.getiAttrId(),attribute.getsName(),attribute.getsValue(),date,attribute.getiDeviceId(),attribute.getsUnits(),new ApplicationFieldDTO()));
        }
    }
    return attributeDTOs;
}

其属性为:

public class AttributeDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    private int iAttrId;
    private String name;
    private String value;
    private String date;
    private String units;
    private int iDeviceId;
    private ApplicationFieldDTO appField;

    public AttributeDTO() {}

    public AttributeDTO(int attrId, String name, String value, String date, int deviceId, String units, ApplicationFieldDTO appField) {
        this.iAttrId = attrId;
        this.name = name;
        this.value = value;
        this.date = date;
        this.iDeviceId = deviceId;
        this.units = units;
        this.appField = appField;
    }
}

来自GWT的是call getAttributes()方法,该方法返回AttributeTo的列表

谢谢


共 (4) 个答案

  1. # 1 楼答案

    如果类中只有一个成员不可序列化,则也会出现该错误——因此,该错误也可能出现在ApplicationFieldDTO的定义中

    顺便说一句,除了使用数据传输对象,您还可以使用Gilead,这样即使是延迟加载也可以工作。(但就你现有的申请而言,引入吉利德可能需要很多工作。)

  2. # 2 楼答案

    我也有同样的问题。尝试使用com。谷歌。gwt。使用者客户rpc。IsSerializable而不是Serializable。这对我很有用,我希望能对你有所帮助:)

  3. # 3 楼答案

    我也面临着类似的问题。在我从UI提交值时,异常

    "GWT error: The response could not be deserialized"

    这部电影上映了。我发现整个代码库没有正确打包以转换为。战争档案。我使用Ant构建方法来创建。战争文件

    后来我在eclipse中安装了一个插件,它对我来说运行良好。我使用这个link从eclipse market place安装了这个插件

  4. # 4 楼答案

    请使用ArrayList而不是列表,然后重试

    看看这个post