Re: Can't serialize return result containing inner class??

686 views
Skip to first unread message
Message has been deleted

Charlie Collins

unread,
Sep 18, 2008, 11:14:20 AM9/18/08
to Google Web Toolkit
I am not sure of the status of this, but yes, there is an issue
related to that still open: http://code.google.com/p/google-web-toolkit/issues/detail?id=811&q=inner%20class.

A non static inner class is probably a bit tricky (not impossible
though) for a source code analyzer/compiler to deal with. Try just
making it a top level class and see if that solves it. Or, if the
situation warrants, make Device a static inner class, that should work
too.

On Sep 18, 4:19 am, Barry <bdemc...@gmail.com> wrote:
> Hi, all ...
>
> I have a GWT service that is trying to return a class
> GetDeviceListResult. This class contains an inner class Device.
>
> When the client tries to call the service, the GWT serializer is
> invoked, and it fails to serialize the GetDeviceListResult class,
> saying that the inner class cannot be serialized. (In the example
> below, it's because of the presence of the xxx member.)
>
> Are inner classes not serializable?? ... or am I just doing this
> wrong??
>
> My call is an Async call, if that matters.
>
> Thanks!
>
> ------------------
>
> The service has this declaration:
>         public GetDeviceListResult getDeviceList();
>
> The offending GetDeviceListResult class (containing the Device inner
> class) is:
>
> package org.paceproject.palms.browserproxy.client.messages;
> import com.google.gwt.user.client.rpc.IsSerializable;
> public class GetDeviceListResult implements IsSerializable {
>         private class Device implements IsSerializable {
>                 public Device() {       }
>         }
>         public Device xxx;
>         public GetDeviceListResult() {}
>
> }
>
> The service itself is:
>
> package org.paceproject.palms.browserproxy.server;
> mport org.paceproject.palms.browserproxy.client.DeviceService;
> import
> org.paceproject.palms.browserproxy.client.messages.GetDeviceListResult;
> import com.google.gwt.user.server.rpc.RemoteServiceServlet;
> public class DeviceServiceImpl extends RemoteServiceServlet implements
>                 DeviceService {
>         private static final long serialVersionUID = 1L;
>         public GetDeviceListResult getDeviceList() {
>                 return new GetDeviceListResult();
>         }
>
> }
>
> This is the log:
> [DEBUG] Rebinding
> org.paceproject.palms.browserproxy.client.DeviceService
> [DEBUG] Invoking <generate-with
> class='com.google.gwt.user.rebind.rpc.ServiceInterfaceProxyGenerator'/
>
> [DEBUG] Generating client proxy for remote service interface
> 'org.paceproject.palms.browserproxy.client.DeviceService'
> [DEBUG] Analyzing
> 'org.paceproject.palms.browserproxy.client.DeviceService' for
> serializable types
> [DEBUG] Analyzing methods:
> [DEBUG] public abstract
> org.paceproject.palms.browserproxy.client.messages.GetDeviceListResult
> getDeviceList(java.lang.String studyID)
> [DEBUG] Return type:
> org.paceproject.palms.browserproxy.client.messages.GetDeviceListResult
> [DEBUG]
> org.paceproject.palms.browserproxy.client.messages.GetDeviceListResult
> [DEBUG] Analyzing the fields of type
> 'org.paceproject.palms.browserproxy.client.messages.GetDeviceListResult'
> that qualify for serialization
> [DEBUG] public
> org.paceproject.palms.browserproxy.client.messages.GetDeviceListResult.Device
> xxx
> [DEBUG]
> org.paceproject.palms.browserproxy.client.messages.GetDeviceListResult.Device
> [ERROR] Type
> 'org.paceproject.palms.browserproxy.client.messages.GetDeviceListResult.Device'
> was not serializable and has no concrete serializable subtypes
> [ERROR] Type
> 'org.paceproject.palms.browserproxy.client.messages.GetDeviceListResult'
> was not serializable and has no concrete serializable subtypes
> [ERROR] Deferred binding failed for
> 'org.paceproject.palms.browserproxy.client.DeviceService'; expect
> subsequent failures
Reply all
Reply to author
Forward
Message has been deleted
0 new messages