I am having a heck of a time returning an ArrayList of objects that implement IsSerializable via RPC. The IsSerializable pojo contains one variable, a String, and has a 0 parameter constructor. I have removed the .gwt.rpc file from my war and still I get:
com.google.gwt.user.client.rpc.SerializationException: Type 'com.test.myApp.client.model.Test' 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 = com.test.myApp.client.model.Test@17a9692
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:610)
I am using GWT 2.0.2 with jdk 1.6.0_18.
Any ideas on what might be going on or what I am doing wrong?
Here is the code for the Test class and the remote method is returning ArrayList. I even modified the code for it to just return one instance of Test with the same result: the exception above.
package com.test.myApp.client.model;
import com.google.gwt.user.client.rpc.IsSerializable;
public class Test implements IsSerializable{
private String s;
public Test() {}
public Test(String s) {
this.s = s;
}
public String getS() {
return s;
}
public void setS(String s) {
this.s = s;
}
}
Greatly appreciate the help! Eddy
This may sound silly, but do you have a default constructor for Test in your code, and not just on the version of the code you posted here? I encountered this same error, googled it, tried several of the suggestions here like clean/rebuild, add serialVersionUID, none of it worked. Then I searched more and found a suggestion to make sure your class that you're trying to serialize has a default constructor. Mine didn't, and as soon as I added one, it worked. I don't know why that fixed it, but it did.
I also added an empty constructor to my class that was having the problem, and it worked fine.
The remote method needs to return ArrayList<Test>
, not just ArrayList
, so that GWT understands that instances of Test
will need to be serialised.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With