Is it possible to send generic types over RPC?

115 views
Skip to first unread message

andreas_b

unread,
Oct 8, 2009, 7:02:58 AM10/8/09
to Google Web Toolkit
Hi all.

I have searched the forum and google for some answers, but have been
unable to find a direct answer to my question. So sorry if this has
been answered. In that case, please give me the link to that
discussion.

I'm working on a project where I need to send lots of different data
object over RPC to save them in a database.
I thought, hey let's use some generics and let the type extends
Serializable.

So I defined the synchronous method like this:

<T extends Serializable> DBQueryResult<T> saveObject(T aObject);

and asynchronous version:

<T extends Serializable> void saveObject(T aObject,
AsyncCallback<DBQueryResult<T>> callback);

All data types that I pass to this method implements Serializable and
I have verified that they can be sent when defining separate methods
for them. DBQueryResult has also been successfully serialized and
deserialized before I tried to make this generic.

I get no compilation errors, but during runtime (in hosted mode)I get
the following error:

2009-okt-08 10:21:42
com.google.appengine.tools.development.ApiProxyLocalImpl log
SEVERE: [1254997302431000] javax.servlet.ServletContext log:
DataServiceImpl: An IncompatibleRemoteServiceException was thrown
while processing this call.
com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException:
This application is out of date, please click the refresh button on
your browser. ( Could not locate requested method 'saveObject
(java.io.Serializable)' in interface
'com.borglin.web.teamsite.client.servercomm.DataService' )
at com.google.gwt.user.server.rpc.RPC.decodeRequest(RPC.java:293)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall
(RemoteServiceServlet.java:164)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost
(RemoteServiceServlet.java:86)
.....


Is it not possible to use generics when defining RPC methods? Is there
any other way to avoid having to define separate methods for each data
object that I need to send over?

Thanks in advance!

BR, Andreas

Paul Robinson

unread,
Oct 8, 2009, 10:10:37 AM10/8/09
to google-we...@googlegroups.com

andreas_b

unread,
Oct 9, 2009, 2:17:28 PM10/9/09
to Google Web Toolkit
Hi.

Thanks for your answer.

That bug sure seems similar, but some of the comments suggest that my
usecase has been solved. Not sure if it's the same error either.
Isn't there a good work-around for this? Anyone who has solved this
and can give me some advice?

Thanks.

BR, Andreas

Nathan Wells

unread,
Oct 10, 2009, 2:47:24 PM10/10/09
to Google Web Toolkit
Reply all
Reply to author
Forward
0 new messages