开发者

GWT Tomcat problem to RPC call

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>
<serv开发者_运维问答let-name>callServlet</servlet-name>
<url-pattern>/myproject/call</url-pattern>
</servlet-mapping>


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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜