I have a GWT shared-package class as follows:
public class MyCustomClass extends TreeSet<MyCustomType> implements Serializable, IsSerializable {
// ... a whole bunch of methods
}
I am trying to send an instance of the class as an object encapsulated in another class, through RPC.
The problem is the TreeSet
, as GWT refuses to serialize it, no matter what I do. I get an error during runtime:
SEVERE: my-service: An IncompatibleRemoteServiceException was thrown while processing this call. com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException: java.lang.ClassNotFoundException: http: at com.google.gwt.user.server.rpc.RPC.decodeRequest(RPC.java:323)
So, I have all the serialization pre-requisites (default constructor, no final fields, getters and setters, all my instance variables are serializable, implement interfaces, etc.), but this continues to happen.
The thing is, when I switch from TreeSet
to using an ArrayList
instead, everything works fine. In my understanding, this is because I am already using ArrayList
s in a number of services, so GWT knows to whitelist it in the serialization policies.
That understanding came because of this thread. And I've tried the proposed solution from the accepted answer (create a "dummy" service and put a TreeSet
there, I even created a dummy class in my client package and put a TreeSet
as a field), but no luck.
I checked my .gwt.xml just in case, the TreeSet
is not added as a serialization exception.
So, I am pretty much stuck at this point, my workaround is to use the ArrayList and re-pack it into a transient set, but I do not really like that approach.
Any help would be highly appreciated.
(using GWT 2.6)
Update: MyCustomType
implements the Comparable<MyCustomType>
interface, and there is no custom comparator provided to the TreeSet
.