English 中文(简体)
Set the path of web app in META-INF/context.xml?
原标题:

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

问题回答

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





相关问题
Tomcat´s server.xml dynamic configuration

My web application uses the same database configuration as the application XYZ. I have a resource declaration for a context in server.xml, so I have a duplicated configuration (once for web ...

session transfer issue from Tomcat to ASP.Net

I am using Tomcat to host JSP and using IIS 7.0 to host aspx (C# + .Net 3.5 + VSTS 2008), and I have some session transfer issue from JSP page to ASPX page. JSP page is in one domain and all other ...

JSP exception - class not found (tomcat)

I m setting up an existing application on a new Tomcat 5.5 server connecting to a Postgres database (running on Debian Lenny). When I access it I get a series of stack traces with the following root ...

热门标签