I'm using GWT-RPC to create an application. At certain point the server return a Collection using Collections.unmodifiableList(List l) to the client. The client give an error:
[WARN] Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type 'java.util.Collections$UnmodifiableList' 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
So, I need an alternative way to get an only readable Collection, how can I do it? Thanks a lot
my code is the following:
try {
LinkedList all=new LinkedList();
while(res.next()){
all.add(objectFromCursor(res));
}
return Collections.unmodifiableList(all);
} catch (SQLException e) {
throw new ExceptionHandler("Error: "+e.getMessage());
}
private static Film objectFromCursor(ResultSet res) throws SQLException{
Film film=new Film(res.getString(1));
film.setRegista(res.getString(2));
film.setAnnoDiProduzione(res.getInt(3));
return film;
}
An unmodifiable serializable collection seems to be a contradiction in itself. In order to deserialize an object (I consider "deserializable" to be implied by "serializable"), it must be modifiable.
So simply use a modifiable collection to be passed over GWT-RPC.