On 01/04/2022 15:59, Harri Pesonen wrote:
Hello,

while reading the documentation in
https://tomcat.apache.org/tomcat-8.5-doc/config/context.html#Naming
it is not clear to me how to achieve the following:

Have one WAR file with corresponding directory, for example:

app#1.war => app#1 (directory) => /app/1 (context path)

But have another context path pointing to same application:

/app/latest (context path) => app#1 (directory)

I tried adding <Context> to server.xml inside <Host> like:

<Context docBase="app#1 " path="/app/latest"/>

But Tomcat created another directory app#latest from this, and copied app#1 
there.
I would like to avoid having duplicate directories.

Doc says that:
* To define multiple contexts that use a single WAR file or directory, use one 
of the options described in the Naming section above for creating a Context 
that has a path that is not related to the base file name.
* If you want to deploy a WAR file or a directory using a context path that is 
not related to the base file name then one of the following options must be 
used to prevent double-deployment:
** Disable autoDeploy and deployOnStartup and define all Contexts in server.xml
** Locate the WAR and/or directory outside of the Host's appBase and use a 
context.xml file with a docBase attribute to define it.

Don't quite understand what to do.
Do I need add <Context> also to the existing application:

<Context docBase="app#1 " path="/app/1"/>

Or what does "define all Contexts in server.xml" mean?
And what does the second option (Locate the WAR...) mean?

The key part is you need to locate the docBase (the web application WAR or directory) NOT under the appBase ($CATALINA_BASE/webapps). So something like this:

/opt/webapps/myapp-1

and then under $CATALINA_BASE/conf/Catlaina/localhost you'll need two context files:

myapp#1.xml
<Context docBase="/opt/webapps/myapp-1" />

myapp#latest.xml
<Context docBase="/opt/webapps/myapp-1" />

HTH,

MarK

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to