GWT Tomcat RPC 调用问题

发布于 2024-10-31 21:05:40 字数 696 浏览 3 评论 0原文

当我将 war 文件部署到 TOMCAT (tomcat/webapps/ROOT/war) 时,GWT RPC 调用似乎不起作用。

它给了我一个错误:

请求的资源 (/war/myproject/call) 不是 可用。

如果我更改目录结构,然后直接部署 war 内容(而不是 war 目录本身),例如(tomcat/webapps/ROOT/project.html、project.css、project 等...),那么它有效。

有人可以解释一下发生了什么事吗?

我认为可能存在问题:

<servlet>
<servlet-name>callServlet</servlet-name>
<servlet-class>com.myproject.server.dao.Call</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>callServlet</servlet-name>
<url-pattern>/myproject/call</url-pattern>
</servlet-mapping>

GWT RPC call don't seems to work when i deploy my war file to TOMCAT (tomcat/webapps/ROOT/war).

It gives me an error:

The requested resource
(/war/myproject/call) is not
available.

If i change the directory structure and then deploy directly war contents (not war directory itself), like (tomcat/webapps/ROOT/project.html, project.css, project, etc...) then it works.

Can someone please explain me whats going on?

I think there might a problem at:

<servlet>
<servlet-name>callServlet</servlet-name>
<servlet-class>com.myproject.server.dao.Call</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>callServlet</servlet-name>
<url-pattern>/myproject/call</url-pattern>
</servlet-mapping>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

独留℉清风醉 2024-11-07 21:05:40

事实是,单个 Tomcat 服务器可以部署多个应用程序,每个应用程序都在其所谓的上下文中。应用程序部署在 webapps 文件夹中,每个文件夹都映射到一个上下文,而 ROOT 文件夹是默认文件夹(无上下文) 。

要访问 Tomcat 上的应用程序,请在 URL 后指定上下文。例如,如果您在 webapps/Test 文件夹中有一个应用程序(上下文)Test,您可以像这样访问它:

http://localhost:8080/Test

但是 ROOT 中的应用程序文件夹没有上下文,只需访问 localhost:8080 即可访问。这就是你的情况。 Tomcat 直接在 ROOT 文件夹中查找您的应用程序,但您的应用程序位于 ROOT/war 文件夹中。换句话说,RPC 调用期望 myproject 文件夹位于 ROOT 文件夹下,而不是位于 ROOT/war 文件夹下。这就是为什么它不起作用。

如果您仍希望将 war 文件夹放在 ROOT 文件夹中,则必须将 url-pattern 更改为 /war /myProject/call

The thing is that a single Tomcat server can have multiple applications deployed, each in its so-called context. The applications are deployed in the webapps folder and each folder is mapped to one context, while the ROOT folder is the default (no-context).

To access an application on Tomcat, you specify the context after the URL. For example if you had an application (context) Test in webapps/Test folder, you would access it like this:

http://localhost:8080/Test

But applications in the ROOT folder have no context and are accessed by simply going to localhost:8080. And this is your case. Tomcat is looking for you application directly in the ROOT folder but you have your app in the ROOT/war folder. In other words, the RPC call expects the myproject folder to be under the ROOT folder and not under the ROOT/war folder. That's why it's not working.

If you still wanted to have your war folder within the ROOT folder, you would have to change the url-pattern to /war/myProject/call.

帅气称霸 2024-11-07 21:05:40

嗯,我找到了解决方案,这与Tomcat的操作方式有关。

  1. 打开项目 war 目录
  2. 选择所有文件(html/jsp、图像、WEB-INF 等...)
  3. 将所有文件压缩到单个 project.zip archieve
  4. 将project.zip 重命名为project.war
  5. 将project.war 复制到Tomcat /webapps/
  6. 重启 Tomcat 服务器
  7. 现在你会发现 webapps 目录下的 project.war 已经被解压到了一个项目目录中,如果你打开它你会发现所有的 .war 内容(html/jsp、图片、WEB-INF、等等...)
  8. 从这里访问它 http://localhost/projecthttp://localhost/project/index.html 或index.jsp。

错误是:我只将 war 目录(而不是内部内容)压缩到 project.war 中。

Well i found the solution, it had to do with Tomcat's way of operation.

  1. Open your project war directory
  2. Select all the files (html/jsp , images, WEB-INF etc...)
  3. Compress all the files into a single project.zip archieve
  4. Rename the project.zip into project.war
  5. Copy project.war into Tomcat/webapps/
  6. Restart Tomcat server
  7. You will now notice inside webapps directory that project.war has been decompressed into a project directory, if you open it you will find all the .war contents(html/jsp, images, WEB-INF, etc...)
  8. Access it from here http://localhost/project or http://localhost/project/index.html or index.jsp.

The error was: I was compressing only the war directory (not it's inside contents) into project.war.

夏见 2024-11-07 21:05:40

看起来,Servlet 没有为您初始化,尝试将 SERVLET 标记更改为
即添加标签,

<load-on-startup>1</load-on-startup>

此标签确保应加载 servlet

 <servlet>
 <servlet-name>callServlet</servlet-name>
 <servlet-class>com.myproject.server.dao.Call</servlet-class>
 <load-on-startup>1</load-on-startup>
 </servlet> 

希望这会起作用

look like, servlet is not initializing for you war try to change SERVLET tag as
i.e. add tag

<load-on-startup>1</load-on-startup>

this tag ensures that servlet should be loaded

 <servlet>
 <servlet-name>callServlet</servlet-name>
 <servlet-class>com.myproject.server.dao.Call</servlet-class>
 <load-on-startup>1</load-on-startup>
 </servlet> 

hopefully this will work

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文