Strange GWT serialization exception when overiding method of serialized object
        Posted  
        
            by Flueras Bogdan
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Flueras Bogdan
        
        
        
        Published on 2010-04-19T13:22:30Z
        Indexed on 
            2010/04/19
            13:23 UTC
        
        
        Read the original article
        Hit count: 378
        
gwt-rpc
|overriding
Hi there!
I have a GWT serializable class, lets call it Foo. Foo implements IsSerializable, has primitive and serializable members as well as other transient members and a no-arg constructor.
class Foo implements IsSerializable {
 // transient members
 // primitive members
  public Foo() {}
  public void bar() {}
}
Also a Service which handles RPC comunication.
// server code
public interface MyServiceImpl {
  public void doStuff(Foo foo);
}
public interface MyServiceAsync {
       void doStuff(Foo foo, AsyncCallback<Void> async);
}
How i use this:
private MyServiceAsync myService = GWT.create(MyService.class);
Foo foo = new Foo();
...
AsyncCallback callback = new new AsyncCallback {...};
myService.doStuff(foo, callback);
In the above case the code is running, and the onSuccess() method of callback instance gets executed.
But when I override the bar() method on foo instance like this:
Foo foo = new Foo() {
public void bar() {
 //do smthng different
}
}
 AsyncCallback callback = new new AsyncCallback {...};
 myService.doStuff(foo, callback);
I get the GWT SerializationException.
Please enlighten me, because I really don't understand why.
© Stack Overflow or respective owner