Reputation: 4383
I've written a quick GWT app with the following code:
MyTaskService
package com.google.gwt.mytasks.client;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("taskAction")
public interface MyTasksService extends RemoteService {
public void addTask(String title, String description);
}
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>MyTasks.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>MyTasksService</servlet-name>
<servlet-class>com.google.gwt.mytasks.server.MyTasksServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyTasksService</servlet-name>
<url-pattern>/mytasks/taskAction</url-pattern>
</servlet-mapping>
</web-app>
Module.gwt.xml
<module rename-to='mytasks'>
<inherits name="com.google.gwt.user.User"/>
<inherits name="com.google.gwt.user.theme.standard.Standard"/>
<entry-point class="com.google.gwt.mytasks.client.MyTasks"/>
<!-- Specify the paths for translatable code -->
<source path='client'/>
<source path='shared'/>
</module>
Every time I click on the submit button I get the following error:
com.google.gwt.user.client.rpc.StatusCodeException: 404 Error 404 NOT_FOUND
HTTP ERROR: 404
NOT_FOUNDRequestURI=/com.google.gwt.mytasks.MyTasks/taskAction
Powered by Jetty://
Upvotes: 1
Views: 3096
Reputation: 839
The problem seems to be that GWT isn't renaming the module before publishing, i you have a look at RemoteServiceRelativePath annotation documentation it defines the servlet path as GWT.getModuleBaseURL() + value(), being value() the value given to the annotation. One easy solution that might work would be to define the servlet mapping at the path the module is looking at.
Instead of:
<servlet-mapping>
<servlet-name>MyTasksService</servlet-name>
<url-pattern>/mytasks/taskAction</url-pattern>
</servlet-mapping>
Use:
<servlet-mapping>
<servlet-name>MyTasksService</servlet-name>
<url-pattern>/com.google.gwt.mytasks.MyTasks/taskAction</url-pattern>
</servlet-mapping>
Upvotes: 4