You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Bob DeRemer <bo...@thingworx.com> on 2014/01/13 18:38:38 UTC

META-INF/Context.xml path question

We're trying to determine if it's possible to build a WAR with an embedded META-INF/Context.xml that defines the webapp path to be different then the WAR file name.   Let's say we have AppServer-<version>.war, but we want to access it as: http://<host>/Server.   In addition, we want to support uploading/installing the WAR both from the Manager app as well as using ftp/command-line to copy the WAR and restart Tomcat.  This way, it's pretty much automatic without editing/creating additional XML files.

If this works, then we can have identifiable WAR files, but with a common/standard webapp path.

We have reviewed the docs and the only approach that has worked for us is adding a separate Context element to the <Tomcat>/conf/Server.xml file.

Thanks,

_________________________________________________________
ThingWorx, a PTC owned company

Bob DeRemer, Sr. Director Architecture/Development
bob.deremer@thingworx.com<ma...@thingworx.com> | www.thingworx.com<http://www.thingworx.com/> | www.ptc.com<http://www.ptc.com/>
M: 717.881.3986 | O: 610.594.6200 x 812


RE: META-INF/Context.xml path question

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Bob DeRemer [mailto:bob.deremer@thingworx.com] 
> Subject: META-INF/Context.xml path question

> We're trying to determine if it's possible to build a WAR with an embedded 
> META-INF/Context.xml that defines the webapp path to be different then the 
> WAR file name.

Short answer: no.

> Let's say we have AppServer-<version>.war, but we want to access it as: 
> http://<host>/Server.

Just rename the .war file to Server.war as part of the deployment.  No muss, no fuss.

> We have reviewed the docs and the only approach that has worked for us is 
> adding a separate Context element to the <Tomcat>/conf/Server.xml file.

Along with the statement that putting <Context> elements in server.xml (not Server.xml) is strongly discouraged - don't do that.  You can keep the .war file outside of any <Host> appBase, and create an <appName>.xml file in conf/Catalina/[host] with a path attribute inside the <Context> element that points to the .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: META-INF/Context.xml path question

Posted by Konstantin Kolinko <kn...@gmail.com>.
2014/1/13 Bob DeRemer <bo...@thingworx.com>:

Tomcat version =?

> We're trying to determine if it's possible to build a WAR with an embedded META-INF/Context.xml that defines the webapp path to be different then the WAR file name.

Not possible.

BTW, the file name is "context.xml" (case sensitively).

>  Let's say we have AppServer-<version>.war, but we want to access it as: http://<host>/Server.

Rename your war file to  ROOT.war or  ROOT##AppServer-<version>.war.

The latter naming works on Tomcat 7 and 8 only.

>  In addition, we want to support uploading/installing the WAR both from the Manager app as well as using ftp/command-line to copy the WAR and restart Tomcat.  This way, it's pretty much automatic without editing/creating additional XML files.
>
> If this works, then we can have identifiable WAR files, but with a common/standard webapp path.
>
> We have reviewed the docs and the only approach that has worked for us is adding a separate Context element to the <Tomcat>/conf/Server.xml file.

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


RE: META-INF/Context.xml path question

Posted by Bob DeRemer <bo...@thingworx.com>.

> -----Original Message-----
> From: Mark Thomas [mailto:markt@apache.org]
> Sent: Monday, January 13, 2014 3:16 PM
> To: Tomcat Users List
> Subject: Re: META-INF/Context.xml path question
> 
> On 13/01/2014 17:38, Bob DeRemer wrote:
> > We're trying to determine if it's possible to build a WAR with an
> > embedded META-INF/Context.xml
> 
> It is context.xml, not Context.xml. Case matters.
> 
> > that defines the webapp path to be
> > different then the WAR file name.
> 
> No, it is not possible to do this.
> 
> >   Let's say we have
> > AppServer-<version>.war, but we want to access it as:
> > http://<host>/Server.   In addition, we want to support
> > uploading/installing the WAR both from the Manager app as well as
> > using ftp/command-line to copy the WAR and restart Tomcat.  This way,
> > it's pretty much automatic without editing/creating additional XML
> > files.
> >
> > If this works, then we can have identifiable WAR files, but with a
> > common/standard webapp path.
> 
> The way to have identifiable WARs is to use the version element of the
> filename. For example, server##1.0.15.war will be auto-deployed with a
> context path of /server. The version tag can be pretty much anything you like as
> long as the file name is valid. You don't have to be using parallel deployment to
> make use of it.

version syntax works great, thx

> 
> > We have reviewed the docs and the only approach that has worked for us
> > is adding a separate Context element to the <Tomcat>/conf/Server.xml
> > file.
> 
> It is server.xml. Again, case matters.
> 
> Mark
> 
> ---------------------------------------------------------------------
> 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: META-INF/Context.xml path question

Posted by Mark Thomas <ma...@apache.org>.
On 13/01/2014 17:38, Bob DeRemer wrote:
> We're trying to determine if it's possible to build a WAR with an
> embedded META-INF/Context.xml

It is context.xml, not Context.xml. Case matters.

> that defines the webapp path to be
> different then the WAR file name.

No, it is not possible to do this.

>   Let's say we have
> AppServer-<version>.war, but we want to access it as:
> http://<host>/Server.   In addition, we want to support
> uploading/installing the WAR both from the Manager app as well as
> using ftp/command-line to copy the WAR and restart Tomcat.  This way,
> it's pretty much automatic without editing/creating additional XML
> files.
> 
> If this works, then we can have identifiable WAR files, but with a
> common/standard webapp path.

The way to have identifiable WARs is to use the version element of the
filename. For example, server##1.0.15.war will be auto-deployed with a
context path of /server. The version tag can be pretty much anything you
like as long as the file name is valid. You don't have to be using
parallel deployment to make use of it.

> We have reviewed the docs and the only approach that has worked for
> us is adding a separate Context element to the
> <Tomcat>/conf/Server.xml file.

It is server.xml. Again, case matters.

Mark

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