tags:

views:

278

answers:

1

I'm tryin to change the path of a deployed war file in Tomcat. Reading the documentation I can't figure out if this is possible without moving the context-file to the /conf directory.

Is it possible to deploy a war-file without having a external (outside the war) context file and set path to /something

Cheers! Tomas

A: 

Hi Tomas,

there are different ways of deploying a web application on the filesystem:

  1. Copy your WAR file or your web application's directory (including all of its content) to the $CATALINA_BASE/webapps directory.

  2. Create an XML fragment file with just the Context element for your web application, and place this XML file in $CATALINA_BASE/webapps. The web application itself can then be stored anywhere on your filesystem.

If you have a WAR file, you can deploy it by simply copying the WAR file into the directory CATALINA_BASE/webapps. The filename must end with an extension of ".war". Once Tomcat notices the file, it will (by default) unpack it into a subdirectory with the base name of the WAR file. It will then create a context in memory, just as though you had created one by editing Tomcat's server.xml file. However, any necessary defaults will be obtained from the DefaultContext element in Tomcat's server.xml file.

Another way to deploy a web app is by writing a Context XML fragment file and deploying it into the CATALINA_BASE/webapps directory. A context fragment is not a complete XML document, but just one Context element and any subelements that are appropriate for your web application. These files are like Context elements cut out of the server.xml file, hence the name "context fragment."

Taken from: Top Ten Tomcat Configuration Tips

Working with the Context XML will hopefully do what you want!

Regards, Christian

Christian Junk
Thanks christian, but I would still need to have the context.xml file outside the war in both scenarios.
Tomas
These solutions are the only ones I have been able to find. Tomcat 4 apparently supports setting "path" in web-inf/context.xml, but in later version of tomcat, this is ignored.
Jon