You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Yaakov Chaikin <ya...@gmail.com> on 2009/05/18 22:32:00 UTC

Changing default context path

Hi,

I am trying to deploy a WAR with a custom context path. For some reason,
Tomcat still defaults to the WAR file name as the context path...

What I am doing is placing context.xml inside the blah.war under
META-INF/context.xml. Here are the contents of context.xml:
**************************
<?xml version="1.0" encoding="UTF-8"?>

<Context path="/test" />
***************************

For some reason, Tomcat still deploys the blah.war application to /blah, not
to /test.

RE: Changing default context path

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Yaakov Chaikin [mailto:yaakov.chaikin@gmail.com]
> Subject: Re: Changing default context path
> 
> So, is it telling me that I can place bla.xml into META-INF 
> directory with a <Context/> tag in it and the context path
> will change to /bla? I tried that and it didn't work.

No, when inside the webapp, the <Context> element must be in META-INF/context.xml.

> So, are you saying that there is NO way (outside of configuring a
> <Context...> inside the server.xml) to have the name of the WAR file
> be one thing and the context path be something else?

You can keep the webapp outside of the <Host> appBase directory (Tomcat's webapps directory, by default), and place the <Context> element for it in conf/Catalina/[host]/[appName].xml, with a docBase attribute pointing to the actual location of the .war file (or directory).  You still do not use the path attribute; the URL path to the webapp is determined by the name of the .xml file.

> I am looking for a way to carry the context path information 
> inside the WAR itself due to my build process requirements.

You could easily have your deployment script change the name of the .war file when it's copied to the appBase directory.

 - 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


Re: Changing default context path

Posted by Yaakov Chaikin <ya...@gmail.com>.
On Mon, May 18, 2009 at 4:46 PM, Caldarale, Charles R
<Ch...@unisys.com> wrote:
>
> > From: Yaakov Chaikin [mailto:yaakov.chaikin@gmail.com]
> > Subject: Re: Changing default context path
> >
> > Take a look at 5th bullet.
>
> Take a look at the description of the path attribute, which you seem to be ignoring:
>
> "The value of this field must not be set except when statically defining a Context in server.xml, as it will be inferred from the filenames used for either the .xml context file or the docBase."

Oops... I guess, I missed that part... But it does say that the
context path is inferred from .xml context file... So, is it telling
me that I can place bla.xml into META-INF directory with a <Context/>
tag in it and the context path will change to /bla? I tried that and
it didn't work.

So, are you saying that there is NO way (outside of configuring a
<Context...> inside the server.xml) to have the name of the WAR file
be one thing and the context path be something else? I am looking for
a way to carry the context path information inside the WAR itself due
to my build process requirements.

> I already told you.  You need to read all of the doc, not just the parts that please you.

Ouch. Man! Lower you weapon. Just asking a question. (I did have the
"audacity" of missing part of the documentation.)

Thanks for your help,
Yaakov.

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


RE: Changing default context path

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Yaakov Chaikin [mailto:yaakov.chaikin@gmail.com]
> Subject: Re: Changing default context path
> 
> Take a look at 5th bullet.

Take a look at the description of the path attribute, which you seem to be ignoring:

"The value of this field must not be set except when statically defining a Context in server.xml, as it will be inferred from the filenames used for either the .xml context file or the docBase."

> I am just trying to figure out why that doesn't seem to work for me.

I already told you.  You need to read all of the doc, not just the parts that please you.

 - 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


Re: Changing default context path

Posted by Yaakov Chaikin <ya...@gmail.com>.
Hmm... the documentation seems to disagree with you:
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html

Take a look at 5th bullet.

I am just trying to figure out why that doesn't seem to work for me.

Yaakov.

On Mon, May 18, 2009 at 4:34 PM, Caldarale, Charles R <
Chuck.Caldarale@unisys.com> wrote:

> > From: Yaakov Chaikin [mailto:yaakov.chaikin@gmail.com]
> > Subject: Changing default context path
> >
> > Tomcat still defaults to the WAR file name as the context path...
>
> That's how it's defined to work.  The path attribute is not allowed except
> in circumstances that are strongly discouraged.  Change the name of your
> .war file.
>
>  - 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
>
>

Re: Changing default context path

Posted by Pid <p...@pidster.com>.
Caldarale, Charles R wrote:
> The path attribute is not allowed except in circumstances that are strongly discouraged.  

Can I suggest an amendment to the documentation as follows:

- If you specify a context path of an empty string (""), you are
- defining the default web application for this Host, which will

+ If you specify a context path you must be able to prove the Riemann
+ hypothesis.


p




>  - 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: Changing default context path

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Yaakov Chaikin [mailto:yaakov.chaikin@gmail.com]
> Subject: Changing default context path
> 
> Tomcat still defaults to the WAR file name as the context path...

That's how it's defined to work.  The path attribute is not allowed except in circumstances that are strongly discouraged.  Change the name of your .war file.

 - 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