Cannot make RPC call: SerializationException

236 views
Skip to first unread message

Alex

unread,
May 18, 2006, 7:04:13 AM5/18/06
to Google Web Toolkit
Problems during RPC call. This is my remote call code:

public void onClick(Widget widget) {
GuessServiceAsync guessService = (GuessServiceAsync)
GWT.create(GuessService.class);
ServiceDefTarget endpoint = (ServiceDefTarget) guessService;
endpoint.setServiceEntryPoint("/servlet/examples/gwt/guess");
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object object) {
Window.alert("New game begins!");
}

public void onFailure(Throwable throwable) {
Window.alert("Error");
}
};
Window.alert("Calling "+endpoint.getServiceEntryPoint());
guessService.newGame(callback);
}

Running application in Host mode. But not even onFailure executed.
Exception throws to the Shell console:

Exception thrown into JavaScript
java.lang.RuntimeException: Checked exception thrown into JavaScript
(web mode behavior may differ)
at
com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:217)
at
com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:108)
at
org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
at
org.eclipse.swt.internal.ole.win32.IDispatch.Invoke(IDispatch.java:64)
at
org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:487)
at
org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:413)
at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNative(ModuleSpaceIE6.java:336)
at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNativeString(ModuleSpaceIE6.java:235)
at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeString(JavaScriptHost.java:119)
at
examples.gwt.guess.client.GuessService_TypeSerializer.getSerializationSignatureImpl(transient
source for examples.gwt.guess.client.GuessService_TypeSerializer:53)
Caused by: com.google.gwt.user.client.rpc.SerializationException:
java.lang.String
at
examples.gwt.guess.client.GuessService_TypeSerializer.raiseSerializationException(transient
source for examples.gwt.guess.client.GuessService_TypeSerializer:62)
at
com.google.gwt.dev.shell.StaticJavaDispatch.callMethod(StaticJavaDispatch.java:45)
at
com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:117)
at
com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:199)
at
com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:108)
at
org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
at
org.eclipse.swt.internal.ole.win32.IDispatch.Invoke(IDispatch.java:64)
at
org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:487)
at
org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:413)
at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNative(ModuleSpaceIE6.java:336)

My service interface doesn't have String parameters or return types:

public interface GuessService extends RemoteService {
public void newGame();
public int guess(int number);
public boolean isActiveGame();
}

What's wrong? Thanks.

Miguel Méndez

unread,
May 18, 2006, 9:17:06 AM5/18/06
to Google-We...@googlegroups.com
Alex,

You are not doing anything wrong.  This is a bug in the auto generated proxy code.  As a work around please add the following function to your GuessService interface:
 
void workAround(String str);

and the following method to your GuessServiceAsync interface:

void workAround(String str, AsyncCallback callback);

Then add an empty method definition for workAround to your RemoteService derived class that implements GuessService.  That will enable you to compile your code.  Good find.  Had you used a string argument in one of the methods in your service interface or used a class that contained a string field as a method argument, you would not have run into it.  We will get this bug fixed.

On 5/18/06, Alex < Chas...@gmail.com> wrote:

Problems during RPC call. This is my remote call code:

public void onClick(Widget widget) {
     GuessServiceAsync guessService = (GuessServiceAsync)
GWT.create(GuessService.class);
      ServiceDefTarget endpoint = (ServiceDefTarget) guessService;
       endpoint.setServiceEntryPoint ("/servlet/examples/gwt/guess");

      AsyncCallback callback = new AsyncCallback() {
                  public void onSuccess(Object object) {
                      Window.alert("New game begins!");
                  }

                  public void onFailure(Throwable throwable) {
                      Window.alert("Error");
                  }
         };
         Window.alert("Calling "+endpoint.getServiceEntryPoint());
         guessService.newGame(callback);
}

Running application in Host mode. But not even onFailure executed.
Exception throws to the Shell console:

Exception thrown into JavaScript
java.lang.RuntimeException : Checked exception thrown into JavaScript
(web mode behavior may differ)
        at
com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:217)
        at
com.google.gwt.dev.shell.ie.IDispatchImpl.method6 (IDispatchImpl.java:108)

        at
org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
        at
org.eclipse.swt.internal.ole.win32.IDispatch.Invoke(IDispatch.java:64)
        at
org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:487)
        at
org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:413)
        at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNative (ModuleSpaceIE6.java:336)

        at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNativeString(ModuleSpaceIE6.java:235)
        at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeString(JavaScriptHost.java :119)
        at
examples.gwt.guess.client.GuessService_TypeSerializer.getSerializationSignatureImpl(transient
source for examples.gwt.guess.client.GuessService_TypeSerializer:53)
Caused by: com.google.gwt.user.client.rpc.SerializationException :
java.lang.String
        at
examples.gwt.guess.client.GuessService_TypeSerializer.raiseSerializationException(transient
source for examples.gwt.guess.client.GuessService_TypeSerializer:62)
        at
com.google.gwt.dev.shell.StaticJavaDispatch.callMethod (StaticJavaDispatch.java:45)

        at
com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:117)
        at
com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:199)
        at
com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:108)
        at
org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
        at
org.eclipse.swt.internal.ole.win32.IDispatch.Invoke (IDispatch.java:64)

        at
org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:487)
        at
org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:413)
        at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNative (ModuleSpaceIE6.java:336)


My service interface doesn't have String parameters or return types:

public interface GuessService extends RemoteService {
    public void newGame();
    public int guess(int number);
    public boolean isActiveGame();
}

What's wrong? Thanks.







--
Miguel Mendez
GWT Engineer

julien...@gmail.com

unread,
May 18, 2006, 10:02:59 AM5/18/06
to Google Web Toolkit
I had the exact same problem. I spend half the day trying to get it
work, thinking what i was doing was wrong... My service had only a
method with an int parameter and an int return type. After reading
Miguel's post, I added a dummy method taking a String as parameter and
returning a String as well :

service interface =>
String dummy(String dummy);

async interface =>
void dummy(String dummy, AsyncCallback callback);

impl class =>
public String dummy(String dummy) {
return dummy;
}

I don't get the SerializationException anymore, but I get a
ClassNotFoundException on my server implementation class. I think it's
not related at all anyway. Do you I have to do something with my
CLASSPATH ?

You guys at Google are doing great job !

Alex

unread,
May 18, 2006, 2:22:10 PM5/18/06
to Google Web Toolkit
Yes, you are right. I added one parameter to the method and error
disappeared.
Hope this bug will be fixed soon.

Miguel Méndez

unread,
May 23, 2007, 4:05:28 PM5/23/07
to Rahul Vaidya, Google-We...@googlegroups.com
[+gwtc]

Yep, that is allowed.  Based on what you've stated, just add the gwt.typeArgs to the getTable method.  Bascially, any field, method argument that is assignable to a Collection or Map needs a gwt.typeArgs .

FWIW, the RPC Generator for 1.4 will actually warn you about missing gwt.typeArgs.

On 5/23/07, Rahul Vaidya < flame...@gmail.com> wrote:
Whoops, clicked the wrong button, and I suppose I emailed you directly, instead of posting it on the group.  I'll post your response.

I'm trying to put String[][]'s into the Vector...is that allowed? can I use gwt.typeArgs <java.lang.String[][]>, and do I place this annotation within the Service class only?

Can't test it at the moment for myself, I will be able to in an hour.

Thank you,
Rahul Vaidya


On 5/23/07, Miguel Méndez <mme...@google.com > wrote:
I think that the question is what is the Vector supposed to contain?  If it is an array of strings, then that explains the SerializationException.  You need to have a gwt.typeArgs for the return value of your getTable method.


On 5/23/07, Rahul Vaidya <flame...@gmail.com > wrote:
I am getting a similar error in my application, but my only service
method takes a String argument.

public interface AttributeTableService extends RemoteService {
        public Vector getTable(String name);
}

public void getTable(String name, AsyncCallback callback);

The error I get while in hosted mode is this:

[WARN] Exception thrown into JavaScript

java.lang.RuntimeException: Checked exception thrown into JavaScript
(web mode behavior may differ)
        at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNative(ModuleSpaceIE6.java:
435)
        at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNativeVoid(ModuleSpaceIE6.java :
320)
        at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:
141)
        at
edu.uci.web.arcims.gwt.client.AttributeTableService_TypeSerializer.deserialize(transient
source for
edu.uci.web.arcims.gwt.client.AttributeTableService_TypeSerializer:
137)
        at
com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java :
94)
        at
com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:
61)
        at edu.uci.web.arcims.gwt.client.AttributeTableService_Proxy
$1.onCompletionImpl(transient source for
edu.uci.web.arcims.gwt.client.AttributeTableService_Proxy:56)
        at edu.uci.web.arcims.gwt.client.AttributeTableService_Proxy
$1.onCompletionAndCatch(transient source for
edu.uci.web.arcims.gwt.client.AttributeTableService_Proxy:45)
        at edu.uci.web.arcims.gwt.client.AttributeTableService_Proxy
$1.onCompletion(transient source for
edu.uci.web.arcims.gwt.client.AttributeTableService_Proxy:39 )
        at
com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:
107)
Caused by: com.google.gwt.user.client.rpc.SerializationException:
[Ljava.lang.String;/2364883620
        at
edu.uci.web.arcims.gwt.client.AttributeTableService_TypeSerializer.raiseSerializationException (transient
source for
edu.uci.web.arcims.gwt.client.AttributeTableService_TypeSerializer:
134)
        at
com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:
107)
        at
com.google.gwt.dev.shell.ie.IDispatchProxy.invoke (IDispatchProxy.java:
140)
        at
com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:
274)
        at
com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:
177)

        at
org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:
117)
        at org.eclipse.swt.internal.ole.win32.IDispatch.Invoke(IDispatch.java:
64)
        at org.eclipse.swt.ole.win32.OleAutomation.invoke (OleAutomation.java:
493)
        at org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:
417)
        at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNative(ModuleSpaceIE6.java:
402)




--
Miguel




--
Miguel

Rahul Vaidya

unread,
May 23, 2007, 6:08:24 PM5/23/07
to Google Web Toolkit
The previous post was in response to my inquiries, which I
accidentally emailed to Miguel instead of posting:

Collections objects have to be parametrized, in accordance with these
guidelines:
http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.RemoteProcedureCalls.SerializableTypes.html

Arrays of objects should be able to be parametrized, but I was
mistaken earlier; my Vector contains one
String[], one int[], and then multiple String[][]'s. Is there any way
to parametrize this?


Original question:


I am getting a similar error in my application, but my only service
method takes a String argument.

public interface AttributeTableService extends RemoteService {
public Vector getTable(String name);
}

public void getTable(String name, AsyncCallback callback);

Return type is Vector

I'm trying to put String[][]'s into the Vector...is that allowed? can
I use gwt.typeArgs <java.lang.String[][]>, and do I place this
annotation within the Service class only?

The error I get while in hosted mode is this:

On May 23, 1:05 pm, "Miguel Méndez" <mmen...@google.com> wrote:
> [+gwtc]
>
> Yep, that is allowed. Based on what you've stated, just add the
> gwt.typeArgs to the getTable method. Bascially, any field, method argument
> that is assignable to a Collection or Map needs a gwt.typeArgs.
>
> FWIW, the RPC Generator for 1.4 will actually warn you about missing
> gwt.typeArgs.
>

> On 5/23/07, Rahul Vaidya <flamest...@gmail.com> wrote:
>
>
>
>
>
> > Whoops, clicked the wrong button, and I suppose I emailed you directly,
> > instead of posting it on the group. I'll post your response.
>
> > I'm trying to put String[][]'s into the Vector...is that allowed? can I
> > use gwt.typeArgs <java.lang.String[][]>, and do I place this annotation
> > within the Service class only?
>
> > Can't test it at the moment for myself, I will be able to in an hour.
>
> > Thank you,
> > Rahul Vaidya
>

> > On 5/23/07, Miguel Méndez <mmen...@google.com> wrote:
>
> > > I think that the question is what is the Vector supposed to contain? If
> > > it is an array of strings, then that explains the SerializationException.
> > > You need to have a gwt.typeArgs for the return value of your getTable
> > > method.
>

Miguel Méndez

unread,
May 23, 2007, 9:46:52 PM5/23/07
to Google-We...@googlegroups.com
You could create an abstract class/interface which is assignable to IsSerializable and then you can create concrete subtypes one for each type in the vector.

HTH,

On 5/23/07, Rahul Vaidya <flame...@gmail.com> wrote:
com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject (AbstractSerializationStreamReader.java:
61)
        at edu.uci.web.arcims.gwt.client.AttributeTableService_Proxy
$1.onCompletionImpl(transient source for
edu.uci.web.arcims.gwt.client.AttributeTableService_Proxy:56 )
org.eclipse.swt.internal.ole.win32.COMObject.callback6 (COMObject.java:
117)
        at



--
Miguel

Miguel Méndez

unread,
Jul 6, 2007, 10:37:14 AM7/6/07
to Guille, Google-We...@googlegroups.com
[+google-web-toolkit]

I'm not sure what you mean by a dummy method.  There was an old, old bug relating to string but it does not affect GWT 1.3.3.

Are you sure that the query for coleccion and xpath will actually produce results?  In other words, if no elements match your XPathQuery, does the XPathQuery method return null or a zero length String[]?  You can put a breakpoint in your server code to find out.  If onSuccess gets null for result your code code throw an NPE.

Is the NPE being passed to the onFailure method?

Cheers,

{
 Yo me imagino que la causa del NPE es que XPathQuery regressa null pero ay que averiguar si eso es cierto o no.
}

On 7/6/07, Guille <Bec...@gmail.com> wrote:
Hello, first of all I'm not sure if I'm doing this in the right place
cuz i've seen some ppl who had sent you a personal mail instead of
posting in the thread but I'm in a hurry and can't find the right
place to post.

I have this SerializationException error in a method which arguments
are 2 strings and the return value is String[] ( The method searches
in  a XML database and returns the documents id's). I've tried adding
the dummy method and I can now compile the code but still get a NPE as
callback.

I'm using Eclipse 3.2.1 and GWT 1.3.3 for windows.

// Syncronous interface
public interface IRepositorioXML extends RemoteService{
.
.
public String[] XPathQuery(String coleccion, String xpath) throws
Exception;
.
.}

// Asyncronous Interface
public interface IRepositorioXMLAsync {
.
.
public void XPathQuery(String coleccion, String xpath, AsyncCallback
callback) throws Exception;
.
.}

// Implementation in server folder
public class IRepositorioXMLImpl extends RemoteServiceServlet
implements IRepositorioXML{
.
.
public String[] XPathQuery(String coleccion, String xpath) {
.
.
return id_list;
}
...
}

This is the client code:
                 //Create the client proxy
                        IRepositorioXMLAsync RepositorioXML = (IRepositorioXMLAsync)
GWT.create (IRepositorioXML.class);

                //Specify the URL at which our service implementation is running
                        ServiceDefTarget endpoint = (ServiceDefTarget) RepositorioXML;
                        String moduleRelativeURL = GWT.getModuleBaseURL() + "/
IRepositorioXMLImpl";
                        endpoint.setServiceEntryPoint(moduleRelativeURL);


                        AsyncCallback callback = new AsyncCallback() {
                            public void onSuccess(Object result) {

                                String[] resultlist = (String[]) result;
                                        for(int i=0; i < resultlist.length ; i++) {
                                                String res = (String) resultlist[i];
                                                Window.alert("Que pedo???");
                                                 archetypelist.addItem(res);
                                }
                            }
                            public void onFailure(Throwable caught) {
                                try {
                                                        throw caught;
                                                } catch (InvocationException e) {
                                                        // TODO Auto-generated catch block
                                                         Window.alert(e.getMessage());
                                                } catch (Exception e)   {
                                                        Window.alert(e.getMessage());
                                                } catch (Throwable e) {
                                                        Window.alert(e.getMessage());
                                                }

                            }
                          };
                          try {
                                          RepositorioXML.XPathQuery("arquetipos", query, callback);
                                  } catch (Exception e) {
                                        // TODO Auto-generated catch block
                                        System.err.println(e.getMessage());
                                }

PD: If you speak spanish and the answer to my question won't be posted
I'd really apreciate to keep spanish since it's way easier for me to
understand.




--
Miguel

Miguel Méndez

unread,
Jul 12, 2007, 9:05:53 AM7/12/07
to Guille Tyrion, Google-We...@googlegroups.com
[+google-web-toolkit]

Hola Guille,

Bueno, yo no e usado este servicio antes.  Me imagino que si lo inicias en tomcat usando web.xml lo pudieras aser si modificas el web.xml que GWT genera para ti.  Si tienes que usar un API lo puedes iniciar adentro del constructor de tu RemoteServiceServlet subclass.

On 7/11/07, Guille Tyrion <bec...@gmail.com> wrote:
Hola, lamento molestar más, pero creo que he encontrado debuggeando el problema con mi aplicación, la comunicación funciona a la perfección ya, y lo que yo no encontraba era el punto donde fallaba la llamada a mi método. Se trata de una base de datos de documentos XML llamada Xindice de Apache. Esta aplicación rueda sobre un servidor jetty y se inicia mediante linea de comandos, pero tambien puede hacerlo en tomcat, solo que la implementación que lleva al iniciarlo desde el cmd es jetty. El caso es que desarrollando mi aplicación java si que conectaba con la base de datos perfectamente, pero la aplicación en GWT no consigue conectar con el servicio, como si fuese transparente, a pesar de que puedo conectar con el servicio en cualquier navegador por http iniciandolo desde la linea de comandos. Es posible integrar este servicio en el servidor apache que da servicio a GWT para usar estas dos herramientas conjuntamente? Si es así y puedes darme una guía, una dirección con información al respecto (en ingles o castellano que para leer no tengo ningún problema :P) o solo con que me digas que es posible ya lo investigaré y conseguiré tarde o temprano ;). Un saludo y lamento si comienzo a ser un incordio jejeje.Gracias!


On 7/11/07, Guille Tyrion < bec...@gmail.com> wrote:
Hola Miguel, ahora voy a probar copiar la query a mano y ejecutarla sobre el repositorio, pero bueno, la query la extraje de una colección de pruebas que hice anteriormente y devlvía resultado. Solo tengo un documento en el repositorio. Sobre lo del dummy, leyendo en el grupo sobre errores similares había un metodo dummy o workaround creo que le llamabas que hace que puedas compilar el código, no obstante sigue dando el mismo error. Por cierto, si que llega el error a onFailure. Voy a hacer pruebas, un amigo me dijo que intente con una clase propia que implemente IsSerializable. Es la otra prueba que tengo pendiente de hacer. Muchisimas gracias por tu respuesta y a ver si saco el repositorio adelante!!!
--
Pues ya ves truz!



--
Pues ya ves truz!



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