i want to serialize a bean that has a field of type java.util.List<T>
but while serializing i get following error message:
com.google.gwt.user.client.rpc.SerializationException: Type
'java.util.Collections$UnmodifiableRandomAccessList' 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 = [...]
i think the problem is that on the server i use
Collections.unmodifiableList(..) or Collections.emptyList(..) to
populate that field, but the GWT compiler does not find those
subclasses.
any idea?
thanks in advance
Michael
For the unmodifiable list, I'd just suggest not sending your list
through that filter. If you need that functionality, you'll have to
create your own implementation.
For the empty list, I'm not really understanding the point. Couldn't
you just return "new ArrayList()"? I know that ArrayList is emulated,
so it would work.
thanks for your answer.
the point is that on the server (and actually also on the client) that
field should be read-only.
i found the problem in
http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/super/com/google/gwt/emul/java/util/Collections.java
line 114:
TODO: make the unmodifiable collections serializable
so i think i will forget trying to use my server-side beans for client
code.
i will just translate the server-side results to client-only beans.
it is just a lot of work (cpu-time) for nothing, but it would be the
same to convert them to JSON for other frameworks.
thanks
Michael
On Mar 9, 2:41 am, mmoossen <mmoos...@gmail.com> wrote:
> i found the problem inhttp://code.google.com/p/google-web-toolkit/source/browse/trunk/user/...
> line 114:
> TODO: make the unmodifiable collections serializable
>
> so i think i will forget trying to use my server-side beans for client
> code.
> i will just translate the server-side results to client-only beans.
> it is just a lot of work (cpu-time) for nothing, but it would be the
> same to convert them to JSON for other frameworks.
The Google Collections project advertises its ImmutableList<T> class
as being GWT-compatible. You might be able to resort to that project's
Lists.of() method instead of the JDK Collections.unmodifiableList()
method.
Respectfully,
Eric Jablow
Michael