GWT1.6 RPC service with List<Object> in return: Serialization pb

5 views
Skip to first unread message

fvisticot

unread,
Apr 14, 2009, 3:46:46 PM4/14/09
to Google Web Toolkit
I'm using an RPC service witch return a List<Object>.
I have an error:

Caused by: com.google.gwt.user.client.rpc.SerializationException: Type
'com.myclass.MyBean' was not included in the set of types which can be
serialized by this SerializationPolicy or its Class object could not
be loaded.

This pb is referenced in the issue:
Issue 1569: Serialization white list missing types

It seems that the compilier does not include the MyBean class because
the signature is using an Object type.

How to specify that MyBean must be used during the compilation ?

For a workaround, i have specified a dummy class using my MyBean
class..

Is there an other solution ? How to specify the different classes that
can be used in the list ?

Dean S. Jones

unread,
Apr 14, 2009, 8:32:38 PM4/14/09
to Google Web Toolkit
GWT needs to know ALL the types that CAN be serialized to the UI at
compile time. It looks at the RPC parameters and return types,
traces their roots and possible sub-classes, and makes sure the proper
serializers/deserializers are present.

First tho, I ask, what good is a List<Object> ??? Say this worked...
what would you do with the List in the UI?

Second, ONLY Serializable types can be used with RPC, so the Minimum
that makes ANY sense is List<Serializable>. This may work, but the
compiler would then take a large amount of time finding ALL
Serializable classes... bad.

Still, you can then get almost anything in your List... so what do you
do in the client??? Iterate and check instanceof on each item???

IF I had to do this, I would create a "marker interface",

public interface DTO extends Serializable
{
}

and make any class that could be used in the UI implement DTO. the
make it List<DTO>

the compiler would then only generate serializers for anything marked
DTO, and be much more efficient.

STILL, On the client you don't know exactly what you have in the List,
and any solution to that problem will
be slow and error prone.



fvisticot

unread,
Apr 15, 2009, 3:40:55 PM4/15/09
to Google Web Toolkit
Thank you for your response.
The Objects contained in the List<Object> are all Serializable. So i
will try to use List<Serializable> ... and the compiler will take time
to find all Serializable objects !!!
This List<Object> can only contain Object defined in an external jar
file (aproximatively 150 differents objects !!!!) but as i explain
later, i can not modify those serializable objects...

I can not mark my Object with a DTO interface because those objects
are part of an external jar file. Perhaps can i try to implement your
solution by generating a proxy on top of my objects... (i will try)..

Regards,

Fred
Reply all
Reply to author
Forward
0 new messages