【发布时间】:2015-05-07 17:42:24
【问题描述】:
我为使用 eclipse 制作的 GWT 应用程序创建了一个 servlet。当我在 TOMCAT 中部署它时,它运行良好,但在 Glassfish 中我有一个 404 错误。
我没有部署错误,主 html 页面加载良好。但是任何使用 RPC servlet 的东西都会给我这个错误:
com.google.gwt.user.client.rpc.StatusCodeException: 404 Not Found
HTTP Status 404 - Not Found
type Status report
messageNot Found
descriptionThe requested resource is not available.
GlassFish Server Open Source Edition 4.1
我的 web.xml 是这样的:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5" xmlns="http://java.sun.com/xml/ns/javaee">
<!-- Servlets -->
<servlet>
<servlet-name>testServlet</servlet-name>
<servlet-class>com.test.server.testServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testServlet</servlet-name>
<url-pattern>/webclient/test</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>Webclient.html</welcome-file>
</welcome-file-list>
</web-app>
在 RPC 的存根中,我有这个 com.test.client.testService :
@RemoteServiceRelativePath("test")
public interface testService extends RemoteService {
还有 servlet:
public class testServiceImpl extends RemoteServiceServlet implements testService
注意事项:
当应用程序在 tomcat 中运行时,如果我在 URL 中写入 servlet 名称,则会显示此错误:
localhost:8080/webclient/webclient/test
状态 HTTP 405 - 此 URL 不支持方法 HTTP GET
看来,其实已经加载好了。但是什么时候在 Glassfish:
HTTP 状态 404 - 未找到
我错过了什么?谢谢!
【问题讨论】:
-
我猜问题是你在 web.xml 中定义了
/webclient/test,但在RemoteServiceRelativePath中只定义了test。您可以尝试将两者都设置为test并打开localhost:8080/webclient/test吗?另外,Tomcat 和 Glassfish 上的上下文路径webclient是吗?
标签: java tomcat servlets gwt glassfish