0

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!!!

GingerHead
  • 8,130
  • 15
  • 59
  • 93
Jose Hdez
  • 2,297
  • 7
  • 38
  • 52

4 Answers4

1

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.)

Johanna
  • 5,223
  • 1
  • 21
  • 38
0

use ArrayList instead of List and try again

Look at this post.

Community
  • 1
  • 1
GingerHead
  • 8,130
  • 15
  • 59
  • 93
  • `new ApplicationFieldDTO()` maybe this is it? Is this class serialized or has an empty constructor, doesn't use generic types like List??? – GingerHead Apr 11 '12 at 07:06
  • ApplicationDTO is another DTO class and the code is: public class ApplicationFieldDTO implements Serializable{ public ApplicationFieldDTO(){} } – Jose Hdez Apr 11 '12 at 07:16
  • Look at this Look at this [post][1] [1]: http://stackoverflow.com/questions/5553593/gwt-jpa-the-response-could-not-be-deserialized – GingerHead Apr 11 '12 at 07:45
0

I had the same trouble. Try to use com.google.gwt.user.client.rpc.IsSerializable instead of Serializable. It worked for me and I hope will help to you :)

cardamo
  • 853
  • 4
  • 13
  • At first development I had com.google.gwt.user.client.rpc.IsSerializable and afterwards I changed by java.io.Serializable because it does not work. I think that it is not the problem, but thanks for your response – Jose Hdez Apr 11 '12 at 06:37
  • @JoseHdez Could you attach stack trace of exception to the question? – cardamo Apr 11 '12 at 06:43
0

I also faced a similar issue. In my case on submitting a value from UI, exception

"GWT error: The response could not be deserialized"

was shown. What I found was that the entire code base was not packed correctly to convert into .war file. I was using Ant Build method for creating .war files.

Later I installed a plugin in eclipse and it worked fine for me. I installed the plugin from eclipse market place using this link

Prashant Kumar
  • 2,057
  • 2
  • 9
  • 22