Ok, it is a bit disappointing that Tomcat does not support this in standard 
webapps folder.
But I found an easy workaround: create Windows junction app#latest that points 
to app#1 folder (both in webapps).

-Harri

-----Original Message-----
From: Mark Thomas <ma...@apache.org> 
Sent: perjantai 1. huhtikuuta 2022 18.46
To: users@tomcat.apache.org
Subject: Re: Two context paths to same application

On 01/04/2022 15:59, Harri Pesonen wrote:
> Hello,
> 
> while reading the documentation in
> https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Ftomc
> at.apache.org%2Ftomcat-8.5-doc%2Fconfig%2Fcontext.html%23Naming&amp;da
> ta=04%7C01%7Charri.pesonen%40sinch.com%7Cdac1869da5b046b4f23e08da13f6c
> c02%7C3b518aae89214a7b8497619d756ce20e%7C0%7C0%7C637844248015649619%7C
> Unknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1h
> aWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=vHZmEqMaCuKbja9GN1vHfCgD5pEKVLzYsb
> L21ZaJtvg%3D&amp;reserved=0 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


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

Reply via email to