GWT+Glassfish 4:RPC servlet出现错误404



我为使用eclipse制作的GWT应用程序创建了一个servlet。当我在TOMCAT中部署它时,效果很好,但在Glassfish中我有一个404错误。

我没有部署错误,主html页面加载良好。但是任何使用RPCservlet的东西都会给我这个错误:

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-未找到

我缺少什么?谢谢

TOMCAT中GET的行为是正确的(405)。。但是404很奇怪。你的Glassfish日志中有更多信息吗。检查这些项目。。。

0)。检查URL的模式。URL应为http://hostname/nameOfWAR/{urlPatter_into_web.xml}

1) 。做一个测试,只是在web应用程序的根上部署一个HelloWord.jsp。。并检查应用程序是否部署良好,显示一些结果。。

2) 。假设"webclient"是您的WAR应用程序,您是否在部署到Glassfish时将gwt-user-xxx.jar导出或包含在应用程序中?如果您使用Eclipse,您可以使用Deployment Assembly,或者只将jar定位到war的lib位置。

3.)检查已编译的gwt类上的序列化策略文件是否存在问题。这是一个.gwt.rpc文件。。。这必须在类路径上。如果这是问题,那么应该通过ug异常等获得更多信息。[也可以覆盖此文件的位置,覆盖SerializationPolicy]

尝试将@RemoteServiceRelativePath("test")更改为@RemoteServiceRelativePath("/webclient/test")

一般来说,<servlet-mapping>元素的形式应该是应用程序的绝对目录路径。您可以阅读这篇有用的文章http://www.gwtproject.org/doc/latest/tutorial/RPC.html

请注意,类的名称应使用大写字母。我知道,也许这是一个测试项目,但很快就会习惯糟糕。

已解决!我没有查看glassfish的server.log。RPC servlet的强制转换出现错误:

rpcservlet不能转换为javax.servlet.servlet

问题是我把libs搞砸了,并在类路径中添加了javax*,而Glassfish不需要这个。我删除了我在domain/lib/ext中留下的所有额外的库,并且工作得很好。

感谢您的支持!

最新更新