Hi to all, I tried to test the demo to understand Introduction to GWT Remote Procedure Calls (RPC) (with example application)
http://www.ajaxmatters.com/articles/gwt/rpc_remote_procedure_calls_example_p1.aspx But when run the application, GWT tell me: [WARN] Module declares a servlet class 'com.test.MyFirstRPC.server.NumsServiceImpl' with a mapping to '/ com.test.MyFirstRPC.Test/', but the web.xml has no corresponding mapping; please add the following lines to your web.xml: <servlet- mapping> <servlet-name>numsServiceImpl</servlet-name> <url-pattern>/ com.test.MyFirstRPC.Test/</url-pattern> </servlet-mapping> Now i have add the line in web.xml but i still have problems :-( Can you help me to run the demo? Following files: Test.java package com.test.MyFirstRPC.client; import com.google.gwt.core.client.EntryPoint; /** * Entry point classes define <code>onModuleLoad()</code>. */ public class Test implements EntryPoint { private Button clickMeButton; public void onModuleLoad() { final TextBox IsEvenTxt = new TextBox(); IsEvenTxt.setText("6"); final NumsServiceAsync NumsService = (NumsServiceAsync) GWT.create(NumsService.class); ServiceDefTarget endpoint = (ServiceDefTarget) NumsService; endpoint.setServiceEntryPoint(GWT.getModuleBaseURL() + "Nums"); RootPanel rootPanel = RootPanel.get(); clickMeButton = new Button(); rootPanel.add(IsEvenTxt); rootPanel.add(clickMeButton); clickMeButton.setText("Click me!"); clickMeButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Window.alert("Hello, GWT World!"); AsyncCallback callback = new AsyncCallback() { public void onSuccess(Object result) { if (((Boolean) result).booleanValue()) { Window.alert("Yes, " + IsEvenTxt.getText() + "' is a Even number."); } else { Window.alert("No, " + IsEvenTxt.getText() + "' is not a Even number."); } } public void onFailure(Throwable caught) { Window.alert("Error while calling the Nums Service."); } }; //NumsService.isEven(6, callback); NumsService.isEven(Integer.parseInt(IsEvenTxt.getText()), callback); // } } }); } } NumService.java package com.test.MyFirstRPC.client; import com.google.gwt.user.client.rpc.RemoteService; /** * @author giancarloalbanese * */ public interface NumsService extends RemoteService { public boolean isEven(int numberToVerify); } NumServiceAsync.java package com.test.MyFirstRPC.client; import com.google.gwt.user.client.rpc.AsyncCallback; /** * @author giancarloalbanese * */ public interface NumsServiceAsync { public void isEven(int numberToVerify, AsyncCallback<Boolean> callback); } NumServiceImpl.java package com.test.MyFirstRPC.server; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.test.MyFirstRPC.client.NumsService; /** * @author giancarloalbanese * */ public class NumsServiceImpl extends RemoteServiceServlet implements NumsService { private static final long serialVersionUID = -8620968747002510678L; public boolean isEven(int numberToVerify) { boolean numIs = false; if ((numberToVerify % 2) == 0) { numIs = true; //break; } return numIs; } } Test.gwt.xml <module> <inherits name="com.google.gwt.user.User"/> <inherits name="com.google.gwt.user.theme.standard.Standard"/> <entry-point class="com.test.MyFirstRPC.client.Test"/> <!-- Example servlet loaded into servlet container --> <servlet path="/" class="com.test.MyFirstRPC.server.NumsServiceImpl"/ > </module> 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> <!-- Default page to serve --> <welcome-file-list> <welcome-file>Test.html</welcome-file> </welcome-file-list> <servlet> <servlet-name>numsServiceImpl</servlet-name> <servlet-class>com.test.MyFirstRPC.server.NumsServiceImpl</servlet- class> </servlet> <servlet-mapping> <servlet-name>numsServiceImpl</servlet-name> <url-pattern>/com.test.MyFirstRPC.Test</url-pattern> </servlet-mapping> </web-app> -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
