yet another IncompatibleRemoteServiceException during serialization question

97 views
Skip to first unread message

Alexey

unread,
Jun 20, 2007, 2:39:04 PM6/20/07
to Google Web Toolkit
I recently delved into GWT (using Ant and Tomcat, no Eclipse) and so
far I'm quite happy with it with a few minor annoyances. One big
stumbling block I've hit though is a serialization problem when trying
to get RPC results back from the server to the client. The plumbing
is quite simple: client RPC's to the server, server talks to the
database via a thin JDBC wrapper logic and sends the resulting object
to the client. Here is the interface in question:

public interface QueryService extends RemoteService
{
/**
* @gwt.typeArgs <com.ge.taxlocid.client.CityBean>
*/
public List searchLocations(String query);

public String searchLocationsString(String query);
}

You'll notice two methods. The second method (searchLocationsString)
is meant to be a debug-only wrapper around searchLocations, which
simply calls toString on the resulting list object. I was able to
ascertain that this works all the way through back to the client. At
that point I moved on to calling searchLocations in an attempt to
retrieve the actual list object.

Notice the typeArgs annotation specifying the result to be a list of
CityBean objects. The hierarchy of that class is as follows:

StateBean implements IsSerializable
^
|
CountyBean implements IsSerializable
^
|
CityBean implements IsSerializable

I wasn't sure if IsSerializable lost its magical powers similar to
Serializable upon subclassing, so I made each class explicitly
implement it.

Based on the server logs, I do know that the RPC servlet is in fact
receiving the call, performs the query and gets the right objects,
just as it did with searchLocationsString. So the only unknown is
what happens when that servlet hands the resulting object off to the
transport layer. Here's what the client code looks like:

protected void search()
{
QueryServiceAsync queryServiceProxy =
(QueryServiceAsync)GWT.create(QueryService.class);
String serviceEntryPoint = GWT.getModuleBaseURL() + "query";

((ServiceDefTarget)queryServiceProxy).setServiceEntryPoint(serviceEntryPoint);
queryServiceProxy.searchLocations(this.locIDInput.getText(),
this.searchCallback);
}

As the subject of this post states, I keep getting
IncompatibleRemoteServiceException on the client. Any thoughts? Oh
and I did see the post about Boolean problems and the bean classes do
not have any boolean or Boolean fields.

Miguel Méndez

unread,
Jun 20, 2007, 2:56:05 PM6/20/07
to Google-We...@googlegroups.com
Hi Alexey,

When the client receives a type from the server that it cannot deserialize it will treat it as an IncompatibleRemoteServiceException.

What is the concrete type of the List that you are returning?  If it is not an ArrayList or Vector proper then that is most likely the source of the problem.  Our client-side JRE only supports ArrayList and Vector.

People usually run into this problem by returning the result of calling Arrays.asList(...).    If it is an ArrayList or Vector proper there maybe an issue with the CityBean.

BTW, you only need to have IsSerializable once in your class hierarchy.

HTH,

                String serviceEntryPoint = GWT.getModuleBaseURL () + "query";


((ServiceDefTarget)queryServiceProxy).setServiceEntryPoint(serviceEntryPoint);
                queryServiceProxy.searchLocations(this.locIDInput.getText(),
this.searchCallback);
        }

As the subject of this post states, I keep getting
IncompatibleRemoteServiceException on the client.  Any thoughts?  Oh
and I did see the post about Boolean problems and the bean classes do
not have any boolean or Boolean fields.







--
Miguel

Alexey

unread,
Jun 20, 2007, 2:57:45 PM6/20/07
to Google Web Toolkit
As a quick follow-up, I'd just like to mention that upon converting my
API to returning CityBean[] instead of a List containing CityBean's
and adding a toArray call on the resulting List to convert it to an
array, everything's working. So something must be screwed up with the
List return type declaration on my end.

Alexey

unread,
Jun 20, 2007, 3:04:41 PM6/20/07
to Google Web Toolkit
That was it! I was using LinkedList. After switching to ArrayList,
it's all working. Thank you very much.

On Jun 20, 2:56 pm, "Miguel Méndez" <mmen...@google.com> wrote:
> Hi Alexey,
>
> When the client receives a type from the server that it cannot deserialize
> it will treat it as an IncompatibleRemoteServiceException.
>
> What is the concrete type of the List that you are returning? If it is not
> an ArrayList or Vector proper then that is most likely the source of the
> problem. Our client-side JRE only supports ArrayList and Vector.
>
> People usually run into this problem by returning the result of calling
> Arrays.asList(...). If it is an ArrayList or Vector proper there maybe an
> issue with the CityBean.
>
> BTW, you only need to have IsSerializable once in your class hierarchy.
>
> HTH,
>

Miguel Méndez

unread,
Jun 20, 2007, 3:08:50 PM6/20/07
to Google-We...@googlegroups.com
We need to clamp these off at the server.  Although, it will require additional work on the server to make it a 100% solution.

On 6/20/07, Alexey < inlin...@yahoo.com> wrote:

Gerard Toonstra

unread,
Jun 21, 2007, 7:06:55 AM6/21/07
to Google Web Toolkit

Please note that these issues also sometimes occurs after an
application's update. We had this error three times on different
machines with IE right after the application was updated on the
server. This is using it from Tomcat directly. Removing the cache gets
rid of the error and it will work as planned.

It doesn't always fail at the same point either. One person had
trouble accessing the initial menu, other users couldn't register a
particular data entity, so it's quite random.

I never had a problem yet with Firefox, so it seems to be IE-specific
(IE7).

G>

On Jun 20, 4:08 pm, "Miguel Méndez" <mmen...@google.com> wrote:
> We need to clamp these off at the server. Although, it will require
> additional work on the server to make it a 100% solution.
>

Miguel Méndez

unread,
Jun 21, 2007, 10:41:22 AM6/21/07
to Google-We...@googlegroups.com
In the IncompatibleRemoteServiceException case, we purposely try not to make it fail 100% of the time in the upgrade scenario.  If methods are removed from the service interface then you will get a failure.  If the service methods remain the same then it will only fail if the particular type involved has changed. 

That said that behavior should not be browser specific.  Could it be another problem or does it always come across as an IRSE exception?

--
Miguel
Reply all
Reply to author
Forward
0 new messages