开发者

Deploy GWT to Tomcat (servlet not running)

What is the correct way to deploy a GWT app to Tomcat? I have made a GWT app with server side code (servlets). It works in Hosted mode but only when I copy the WAR folder (after compiling) to Tomcat webapp directory and rename the war folder correctly.

My GWT app servlet is in URI /mygwtapp, so I renamed the folder mygwtapp. The app loads correctly with the problem that servlet do not run 开发者_高级运维i.e. /mygwtapp/servlet does not run.

All the libraries needed by the server side code are in the WEB-INF/lib folder. What could be the reason for this?

Thanks.


By default, Tomcat serves an app named 'mygwtapp' from the context path '/mygwtapp'. (Whereas the GWT built-in jetty serves it from the context path '/'.)

Your servlet paths will usually be '/mygwtapp/*'. This means, that in conjunction with the context path, your servlets are now accessible from '/mygwtapp/mygwtapp/*'. (Try it: Simply enter the full URL in your browser - the Servlet will usually complain that something is missing, or that it doesn't support GET, but you'll know for sure now, where it lives.)

So you have two options:

  1. Tell the client side to call the servlets at '/mygwtapp/mygwtapp/*' (I think, this is already taken care of automatically when using the @RemoteServiceRelativePath annotation)
  2. Adjust the Context path of the web application in Tomcat, as explained in http://tomcat.apache.org/tomcat-6.0-doc/config/context.html


One other option is to use GWT.getModuleBaseURL() then in your client side code append servlet name. This will make it work on jetty or Tomcat without any special config.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜