GWT Tomcat RPC 调用问题
当我将 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
事实是,单个 Tomcat 服务器可以部署多个应用程序,每个应用程序都在其所谓的上下文中。应用程序部署在
webapps
文件夹中,每个文件夹都映射到一个上下文,而ROOT
文件夹是默认文件夹(无上下文) 。要访问 Tomcat 上的应用程序,请在 URL 后指定上下文。例如,如果您在
webapps/Test
文件夹中有一个应用程序(上下文)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 theROOT
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
inwebapps/Test
folder, you would access it like this:But applications in the
ROOT
folder have no context and are accessed by simply going tolocalhost:8080
. And this is your case. Tomcat is looking for you application directly in theROOT
folder but you have your app in theROOT/war
folder. In other words, the RPC call expects themyproject
folder to be under theROOT
folder and not under theROOT/war
folder. That's why it's not working.If you still wanted to have your
war
folder within theROOT
folder, you would have to change theurl-pattern
to/war/myProject/call
.嗯,我找到了解决方案,这与Tomcat的操作方式有关。
错误是:我只将 war 目录(而不是内部内容)压缩到 project.war 中。
Well i found the solution, it had to do with Tomcat's way of operation.
The error was: I was compressing only the war directory (not it's inside contents) into project.war.
看起来,Servlet 没有为您初始化,尝试将 SERVLET 标记更改为
即添加标签,
此标签确保应加载 servlet
希望这会起作用
look like, servlet is not initializing for you war try to change SERVLET tag as
i.e. add tag
this tag ensures that servlet should be loaded
hopefully this will work