gpt4 book ai didi

java - GWT + Glassfish 4 : Error 404 for RPC servlet

转载 作者:行者123 更新时间:2023-11-30 07:02:42 26 4
gpt4 key购买 nike

我为使用 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 的 stub 中,我有这个 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 的模式。网址应为 http://hostname/nameOfWAR/ {urlPatter_into_web.xml}

1). 进行测试以在 Web 应用程序的根目录上部署 HelloWord jsp.. 并检查应用程序是否部署良好并显示一些结果..

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

3.) 检查编译的 gwt 类上的序列化策略文件没有问题。它是一个 .gwt.rpc 文件......这必须在 classpath 上。如果这是问题,应该通过异常等获取更多信息... [也可以覆盖此文件的位置并覆盖 SerializationPolicy]

关于java - GWT + Glassfish 4 : Error 404 for RPC servlet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28893360/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com