You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Peter Rifel <pr...@mixpo.com> on 2014/06/27 02:33:46 UTC

Deploying a relative docBase outside of appBase

Hello,

I am in the process of upgrading from Tomcat 7.0.54 to 8.0.9 and am running into an issue with the location of my exploded war directories.  In Tomcat 7 I had a ROOT.xml file in conf/Catalina/<hostname>/ which contained my Context with a docBase="../../www.war" parameter.  This was able to reach my www.war directory that lived next to my tomcat directory (one directory above CATALINA_HOME, two above webapps).

This doesn't work in Tomcat 8, giving an IAE:

SEVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[<hostname>].StandardContext[]]
…
Caused by: java.lang.IllegalArgumentException: The main resource set specified [/path/to/tomcat/webapps/www.war] is not valid


I stepped through the source code and arrived at o.a.c.webresources.StandardRoot.startInternal().  If the docBase is not absolute, we append the appBase with the docBase's getName() which returns just "the last name in the pathname's name sequence" according the javadocs.

Should this be getPath() instead?  getPath() would return the full relative path that when combined with the appBase, the canonical path will be the correct path to the application.  Is this a bug or is it intentional and is there a better way I should be configuring my context?

I've been testing this in Java 8 but it happens in 7 as well.  Here is my current version info if it matters:

Server version: Apache Tomcat/8.0.9
Server built:   Jun 19 2014 01:54:25
Server number:  8.0.9.0
OS Name:        Mac OS X
OS Version:     10.9.3
Architecture:   x86_64
JVM Version:    1.8.0_05-b13
JVM Vendor:     Oracle Corporation


Thanks in advance,

Peter

Re: Deploying a relative docBase outside of appBase

Posted by Peter Rifel <pr...@mixpo.com>.
Using the catalina.home variable did the trick, thank you!

Peter

On 6/26/14, 7:19 PM, "Caldarale, Charles R" <Ch...@unisys.com>
wrote:

>> From: Peter Rifel [mailto:prifel@mixpo.com]
>> Subject: Deploying a relative docBase outside of appBase
>
>> In Tomcat 7 I had a ROOT.xml file in conf/Catalina/<hostname>/ which
>>contained 
>> my Context with a docBase="../../www.war" parameter.  This was able to
>>reach my 
>> www.war directory that lived next to my tomcat directory (one directory
>>above 
>> CATALINA_HOME, two above webapps).
>
>> This doesn't work in Tomcat 8, giving an IAE
>
>Try this instead:
>
><Context docBase="${catalina.home}/../www.war" />
>
>There might also be some confusion due to the .war extension on the
>directory name, but I thought that was fixed a while back.
>
>> If the docBase is not absolute, we append the appBase with the
>>docBase's getName()
>> which returns just "the last name in the pathname's name sequence"
>>according the 
>> javadocs.
>
>> Should this be getPath() instead?  getPath() would return the full
>>relative path 
>> that when combined with the appBase, the canonical path will be the
>>correct path 
>> to the application.
>
>That does look suspicious.
> 
> - Chuck
>
>
>THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
>MATERIAL and is thus for use only by the intended recipient. If you
>received this in error, please contact the sender and delete the e-mail
>and its attachments from all computers.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
>


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


RE: Deploying a relative docBase outside of appBase

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Peter Rifel [mailto:prifel@mixpo.com] 
> Subject: Deploying a relative docBase outside of appBase

> In Tomcat 7 I had a ROOT.xml file in conf/Catalina/<hostname>/ which contained 
> my Context with a docBase="../../www.war" parameter.  This was able to reach my 
> www.war directory that lived next to my tomcat directory (one directory above 
> CATALINA_HOME, two above webapps).

> This doesn't work in Tomcat 8, giving an IAE

Try this instead:

<Context docBase="${catalina.home}/../www.war" />

There might also be some confusion due to the .war extension on the directory name, but I thought that was fixed a while back.

> If the docBase is not absolute, we append the appBase with the docBase's getName() 
> which returns just "the last name in the pathname's name sequence" according the 
> javadocs.

> Should this be getPath() instead?  getPath() would return the full relative path 
> that when combined with the appBase, the canonical path will be the correct path 
> to the application.

That does look suspicious.
 
 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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