I'm new to GWT and trying to get the simplest project under my belt.
I've got a project that does nothing but send a string from the client
to the server. The server adds a string to that string and returns
it. I've been spinning my wheels on this for days and don't know
where to go from here or what to even ask at this point. I've read
numerous tutorials and sample projects on the subject and it all makes
sense.
My project compiles fine. Then when I try to run "web application" i
get the following message in the browser (Chrome): "
"
HTTP ERROR 404
Problem accessing /MyGWTModule.html. Reason:
NOT_FOUND
"
I also get the following warning in the eclipse console.
[WARN] No file found for: /MyGWTModule.html
[WARN] No file found for: /favicon.ico
I compile and then "run web application". Am I missing a step?
If I zipped the project would someone be willing to take a quick look
at it (via email). Or let me know if there's a better way of sharing
it. Meanwhile, I'll post the project files in this post in hopes that
it will be enough for someone to help.
Also, could someone fill me in on what the Util class is for in the
MyRemoteService interface is for?
Thanks, the help is much appreciated.
**************************************Entry point file
MyGWTModule**************************************************************
package com.mycompany.project.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.core.client.GWT;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class MyGWTModule implements EntryPoint {
//MyRemoteServiceAsync myRSAsync =
MyRemoteServiceAsync.Util.getInstance();
MyRemoteServiceAsync svc = GWT.create(MyRemoteService.class);
AsyncCallback<String> callback = new AsyncCallback<String>() {
public void onSuccess(String result) {
Window.alert(result);
}
public void onFailure(Throwable caught) {
Window.alert("RPC Failed.");
}
};
private Button clickMeButton;
public void onModuleLoad() {
RootPanel rootPanel = RootPanel.get();
clickMeButton = new Button();
rootPanel.add(clickMeButton);
clickMeButton.setText("Click me!");
clickMeButton.addClickHandler(new ClickHandler(){
public void onClick(ClickEvent event) {
Window.alert("Hello, GWT World!");
String s = "ass";
svc.printSomething(s, callback);
Window.alert(s);
}
});
}
}
**************************************End Entry point
file**************************************************************
*************************************MyRemoteService
Interface***************************************************************
package com.mycompany.project.client;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("MyRemoteService")
public interface MyRemoteService extends RemoteService {
/**
* Utility class for simplifying access to the instance of async
service.
*/
public String printSomething(String s);
public static class Util {
private static MyRemoteServiceAsync instance;
public static MyRemoteServiceAsync getInstance(){
if (instance == null) {
instance = GWT.create(MyRemoteService.class);
}
return instance;
}
}
}
*************************************End MyRemoteService
Interface***************************************************************
*************************************MyRemoteServiceAsync
Interface***************************************************************
package com.mycompany.project.client;
import com.google.gwt.user.client.rpc.AsyncCallback;
public interface MyRemoteServiceAsync {
public void printSomething(String s, AsyncCallback<String> callback);
*************************************End MyRemoteServiceAsync
Interface***************************************************************
*************************************MyRemoteServiceImpl
Interface***************************************************************
package com.mycompany.project.server;
import com.mycompany.project.client.MyRemoteService;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
@SuppressWarnings("serial")
public class MyRemoteServiceImpl extends RemoteServiceServlet
implements MyRemoteService {
public String printSomething(String s){
return s + "hole";
}
}
*************************************END MyRemoteServiceImpl
Interface***************************************************************
*************************************MyGWTModule.gwt.xml (auto
generated)
***************************************************************
<module>
<inherits name="com.google.gwt.user.User"/>
<inherits name="com.google.gwt.user.theme.standard.Standard"/>
<entry-point class="com.mycompany.project.client.MyGWTModule"/>
</module>
*************************************END
MyGWTModule.gwt.xml***************************************************************
************************************* web.xml (auto generated)
***************************************************************
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xmlns="
http://java.sun.com/xml/ns/javaee"
xmlns:web="
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<servlet>
<servlet-name>MyRemoteService</servlet-name>
<servlet-class>com.mycompany.project.server.MyRemoteServiceImpl</
servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyRemoteService</servlet-name>
<url-pattern>/com.mycompany.project.MyGWTModule/MyRemoteService</url-
pattern>
</servlet-mapping>
</web-app>
*************************************END web.xml
***************************************************************