error when I use GWT RPC

Posted by Sebe on Stack Overflow See other posts from Stack Overflow or by Sebe
Published on 2011-01-08T10:04:27Z Indexed on 2011/01/08 12:54 UTC
Read the original article Hit count: 1206

Filed under:
|
|

Hello everyone... I have a problem with Eclipse when I use an RPC.. If I use a single method call it's all in the right direction but if I add a new method to handle the server I get the following error:

com.google.gwt.core.client.JavaScriptException: (null): null
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:237)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:126)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeBoolean(ModuleSpace.java:184)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeBoolean(JavaScriptHost.java:35)
    at com.google.gwt.user.client.rpc.impl.RpcStatsContext.isStatsAvailable(RpcStatsContext.java)
    at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:221)
    at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
    at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326)
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:126)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
    at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:214)
    at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
    at java.lang.Thread.run(Thread.java:619)

Can I have more services in an asynchronous call right? Where am I wrong?

This is my implementation MyService:

package de.vogella.gwt.helloworld.client;

import com.google.gwt.user.client.rpc.RemoteService;

public interface MyService extends RemoteService {
    //chiamo i metodi presenti sul server

    public void creaXML(String nickname,String pass,String email2,String gio,String mes, String ann);

    public void setWeb(String userCorrect,String query, String titolo,String snippet,String url);
}

MyServiceAsync

package de.vogella.gwt.helloworld.client;

import com.google.gwt.user.client.rpc.AsyncCallback;

public interface MyServiceAsync {

    void creaXML(String nickname,String pass,String email2,String gio,String mes, String ann,AsyncCallback<Void> callback);

    void setWeb(String userCorrect,String query, String titolo,String snippet,String url, AsyncCallback<Void> callback);
}

RPCService:

package de.vogella.gwt.helloworld.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.ui.FlexTable;

public class RPCService implements MyServiceAsync {
     MyServiceAsync service = (MyServiceAsync) GWT.create(MyService.class);
     ServiceDefTarget endpoint = (ServiceDefTarget) service;


        public RPCService()
        {
            endpoint.setServiceEntryPoint(GWT.getModuleBaseURL() + "rpc");

        }


        public void creaXML(String nickname,String pass,String email2,String gio,String mes, String ann,AsyncCallback callback)
        {
            service.creaXML(nickname, pass, email2, gio, mes, ann, callback);
        }

        public void setWeb(String userCorrect,String query, String titolo,String snippet,String url,AsyncCallback callback) {

            service.setWeb(userCorrect,query, titolo,snippet,url,callback);

        }
}

MyServiceImpl

package de.vogella.gwt.helloworld.server;

import java.io.*;

import org.w3c.dom.*;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import de.vogella.gwt.helloworld.client.MyService;

import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.google.gwt.xml.client.Element;
import com.google.gwt.xml.client.NodeList;

public class MyServiceImpl extends RemoteServiceServlet implements MyService {
    //metodo che inserisce il nuovo iscritto
    public void creaXML(String nickname,String pass,String email2,String gio,String mes, String ann){
        .......
    }

    public void setWeb(String userCorrect,String query, String titolo,String snippet,String url) {
        .....
    }

In the app in client-side I do

RPCService rpc2 = New RPCService()
rpc2.setWeb(..,...,...,...,callback);

and

RPCService rpc = New RPCService()
rpc.creaXML(..,...,...,...,callback); (in other posizions in the code...)

and..

AsyncCallback callback = new AsyncCallback()
{
    public void onFailure(Throwable caught)
    {
        Window.alert("Failure!");
    }

    public void onSuccess(Object result)
    {

        Window.alert("Successoooooo");


    }
}; 

Web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

  <!-- Servlets -->

  <!-- Default page to serve -->
  <welcome-file-list>
    <welcome-file>De_vogella_gwt_helloworld.html</welcome-file>
  </welcome-file-list>

  <servlet>
  <servlet-name>rPCImpl</servlet-name>
  <servlet-class>de.vogella.gwt.helloworld.server.MyServiceImpl</servlet-class>
  </servlet>

  <servlet-mapping>
   <servlet-name>rPCImpl</servlet-name>
   <url-pattern>/de_vogella_gwt_helloworld/rpc</url-pattern>
 </servlet-mapping>

</web-app>

Thank you all for your attention

Sebe

© Stack Overflow or respective owner

Related posts about gwt

Related posts about gwt-rpc