I have developed several GWT Web Applications. Latest one is a little modification of another one. All of them works well except for the latest one. The exception is:
The response could not be deserialized
I am using Hibernate and Data Transfer Objects between Hibernate and GWT. Each DTO implements java.io.Serializable interface. As I said before, in other applications works well. Could someone help me with this error? I do not know what the cause is.
My Hibernate object code is:
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;
}
And AttributeDTO is:
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;
}
}
From GWT is call getAttributes() method which returns a List of AttributeDTO.
Thanks!!!
The error also appears if only one member of your class is not serializable – thus the error also might be in the definition of ApplicationFieldDTO.
By the way, instead of using data transfer objects you also can use Gilead, then even lazy loading is working. (But in the case of your existing application the introduction of Gilead might be a lot of work.)