ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Top Ten Tomcat Configuration Tips
Subject:   Can you define the context of an app in a .war?
Date:   2005-05-26 22:40:04
From:   jason_brittain
Response to: Can you define the context of an app in a .war?

Which deployment options work depends on how Tomcat is configured, and
which version of Tomcat we're talking about.. Assuming 5.5, here are
the ways it could be deployed by hand (neglecting some limiting admin
console program):


1) War up the webapp so it contains a META-INF/context.xml that contains
the Context configuration for the root webapp, and copy either the
resulting .war file or the webapp's expanded dir into the webapps/ dir.
2) Copy the war file (or its expanded dir) into the webapps/ dir, then
place a "ROOT.xml" Context config file into the
$CATALINA_BASE/conf/[enginename]/[hostname]/ directory.
3) Edit server.xml and change/add the root Context config for your
webapp, and restart Tomcat.
4) Use the Admin webapp to deploy the webapp to the URI you desire.
5) Use the manager webapp to deploy the webapp to the URI you desire.
6) If this installation of Tomcat already was running a ROOT webapp
(most are, by default), you could replace the webapps/ROOT directory
entirely with the expanded dir of your own webapp, although the
expanded dir must be named "ROOT". It would only run like that if
your webapp doesn't need any custom Context configuration other than
being mapped to the root URI. A restart of Tomcat may be necessary
as well.


Also, if a ROOT webapp is already configured in server.xml, or in a
context.xml config file, and you try one of the above methods that would
leave the original ROOT webapp config in place, you may get into the
situation where two webapps are configured to be the root webapp, and
only one of them wins. So, again, it depends on how your Tomcat is
configured in the first place.


I hope this helps!