What is the difference between: public/WEB-INF/web.xml & tomcat/webapps/ROOT/WEB-INF/web.xml

617 visningar
Hoppa till det första olästa meddelandet

joster

oläst,
7 nov. 2007 11:14:132007-11-07
till Google Web Toolkit
Hello All-

I am trying to better understand what is the difference between:
public/WEB-INF/web.xml
&
tomcat/webapps/ROOT/WEB-INF/web.xml

Is there any documentation on what settings should go in which file
and what are the differences between two files?

Joster

charlie...@gmail.com

oläst,
7 nov. 2007 19:34:132007-11-07
till Google Web Toolkit
This is gonna be a long answer, but there have been a lot of threads
flying around about this, and the question seems a bit confused, so
here goes . . .

----

Standard Tomcat, not in GWT, uses several main files, each with a
different purpose or scope, to control standard app settings:

1. Global - container wide - [CATALINA_BASE]conf/server.xml (http://
tomcat.apache.org/tomcat-5.5-doc/config/server.html)
This is a Tomcat specific file (not part of the servlet spec) and the
settings in it are global, you really should avoid mucking with this,
it's better, and more portable, to keep your settings in app scope
files like context.xml and web.xml, if possible.

2. Application specific for Tomcat - [APP]/META-INF/context.xml (or
can be placed in other areas and picked up too,
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html). This is
a special Tomcat file (again, not part of the servlet spec), that is
designed to let you control container level stuff on a per application
basis (if you want the container to manage data sources, security
realms, etc).

3. Application specific for a Java Web App - [APP]/WEB-INF/web.xml.
This is not Tomcat specific (is part of the servlet spec), and is
designed to let you setup Java related app settings, filters, session
settings, application context, etc).

---

The GWT Tomcat "Lite" uses several "web.xml" versions of it's own,
because it overrides the standard and doesn't give you the normal
settings - and it gives you a version of "context.xml" too.

1. tomcat/conf/gwt/web.xml is a sort of default that includes mime
types and such, normally you don't muck with this one in GWT.

2. tomcat/webapps/ROOT/WEB-INF/web.xml - this is the deployment
descriptor your app, running in Hosted mode with GWT, will use. If
you want to put settings in "web.xml" and have them matter for hosted
mode, you gotta put em here.

3. tomcat/conf/gwt/localhost/ROOT.xml - this is what your app running
in hosted mode with GWT will use for the standard "context.xml" file.
Put stuff you would put in context.xml here.

GWT overrides the default Tomcat "ROOT" context and pretends to run
your webapp from that location. Normally GWT just includes
GWTShellServlet in the "web.xml" which proxies calls into the servlet
container to the correct classes that implement your RPC calls. IF you
want do do anything fancy in the hosted mode container, then you have
to munge the files yourself.

----

Now, with that background in place, you really asked about the GWT
web.xml for hosted mode (tomcat/webapps/ROOT/WEB-INF/web.xml) versus
"public/WEB-INF/web.xml."

The "public" one means absolutely nothing to GWT in hosted mode.
Outside of GWT it's common to include WEB-INF/web.xml in your source
"webapp" or "web" or what have you directory and then have a build
tool place that inside the WAR where it goes (from source, to dist,
[WARROOT]/WEB-INF/web.xml). Ant is used to moving a "source" web.xml
to the correct output location, so is Maven, and so are many IDE
plugins and such. But, with GWT hosted mode, that file is ignored
even if it's present, because you arent running your app as compiled
into a WAR.

For hosted mode it's tomcat/webapps/ROOT/WEB-INF/web.xml that
matters.

When deployed as a WAR it's [WARROOT]/WEB-INF/web.xml that matters.

So you have to maintain these two, if you have things you want to
matter in hosted mode, and you don't want to just abandon the GWT
tomcat and use -noserver (there are pros and cons there).


HTH, sorry for the long ass post, but this is a confusing subject and
it covers a lot of ground to really clarify it.

Svara alla
Svara författaren
Vidarebefordra
0 nya meddelanden