You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by James Matthews <jx...@gmail.com> on 2010/03/08 22:10:42 UTC

Best Practices for Deployment with separate Context XML file (Tomcat 6.0.20)

Dear all,

My question focuses on the best way to deploy a Web Application to a running
Tomcat instance when specifying the Context Container's configuration in a
separate XML file in  $CATALINA_BASE/conf/[enginename]/[hostname]/

In an ideal world I would like to be able to keep a *permanent*
Application.xml, with environment specific database settings, in
$CATALINA_BASE/conf/[enginename]/[hostname]/ and for deployment simply drop
my Application.war into my appbase to trigger a redeploy. However, in Tomcat
6, the auto-deployment caused by the new WAR being dropped deletes the
existing context XML file.

My question is, what is the best way of deploying given that I need to
deploy a simultaneous WAR and XML file. Copying the WAR first leaves me
without the XML configuration, so do I drop the WAR file and the 'new' (i.e.
identical) XML file simultaneously? Drop the XML file afterwards? Do I turn
of auto-deploy altogether - and if so what's the most pain free way of doing
the deployment to the running Tomcat without auto-deploy?

Many thanks in advance for your advice. I case it adds useful information, I
have included the background to what I'm hoping to achieve below.

Regards,

James



(I would like my Web Application WAR to be deployable on different Tomcat
instances running in different environments, and to have some configuration
(namely the JNDI database config) specified by the environment it is
deployed on rather than within the application itself. These settings are
specified within my <Context> container.

As I understand it there are three places where I can configure my context -
in the server.xml file, in a separate XML file in
$CATALINA_BASE/conf/[enginename]/[hostname]/ and in a context.xml file
stored within the WAR itself.

The server.xml option is now deprecated, and the within-WAR-file option
breaks the goal I have outlined above, so I have gone with the separate XML
file.)


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


Re: Best Practices for Deployment with separate Context XML file (Tomcat 6.0.20)

Posted by James Matthews <jx...@gmail.com>.
Thank you Chuck, you've been most helpful.

Regards,

James

On 8 March 2010 19:41, Caldarale, Charles R <Ch...@unisys.com> wrote:
>> From: James Matthews [mailto:jxmatthews@gmail.com]
>> Subject: RE: Best Practices for Deployment with separate Context XML
>> file (Tomcat 6.0.20)
>>
>> is using a separate Context XML file the best way of providing
>> server-specific configuration to a tomcat web application?
>
> I think so, since otherwise the server administrator has to take the .war file apart, update context.xml or web.xml, and pack it all back together.  Specific values can also be specified by system properties on the command line, and referenced in the webapp's context.xml, but that has its own issues with uniqueness and remembering to set the values when needed.
>
>> Not using the standard webapps folder directly seems like bit
>> of a work-around.
>
> It's the way I prefer to run the production apps, as opposed to the examples, docs, manager, etc., that come with Tomcat.  (We keep the examples and docs deployed just to give people something to play with - there's no outside access to the system.)  Having the production apps outside of the Tomcat directory structure makes it easy to update Tomcat versions when needed - and we do keep up with each release.
>
>  - 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.
>
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________
>
> ---------------------------------------------------------------------
> 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: Best Practices for Deployment with separate Context XML file (Tomcat 6.0.20)

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: James Matthews [mailto:jxmatthews@gmail.com]
> Subject: RE: Best Practices for Deployment with separate Context XML
> file (Tomcat 6.0.20)
> 
> is using a separate Context XML file the best way of providing 
> server-specific configuration to a tomcat web application?

I think so, since otherwise the server administrator has to take the .war file apart, update context.xml or web.xml, and pack it all back together.  Specific values can also be specified by system properties on the command line, and referenced in the webapp's context.xml, but that has its own issues with uniqueness and remembering to set the values when needed.

> Not using the standard webapps folder directly seems like bit 
> of a work-around.

It's the way I prefer to run the production apps, as opposed to the examples, docs, manager, etc., that come with Tomcat.  (We keep the examples and docs deployed just to give people something to play with - there's no outside access to the system.)  Having the production apps outside of the Tomcat directory structure makes it easy to update Tomcat versions when needed - and we do keep up with each release.

 - 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.


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

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


Re: Best Practices for Deployment with separate Context XML file (Tomcat 6.0.20)

Posted by Mark Thomas <ma...@apache.org>.
On 08/03/2010 22:47, James Matthews wrote:
> Thank you so much Chuck, that works perfectly (interestingly each 'touch'
> still only instigates the "Undeploy" log in catalina.out, but the
> application does now redeploy seamlessly).

Thats a 'feature'. It is fixed in 6.0.24 onwards.

Mark



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


RE: Best Practices for Deployment with separate Context XML file (Tomcat 6.0.20)

Posted by James Matthews <jx...@gmail.com>.
Thank you so much Chuck, that works perfectly (interestingly each 'touch'
still only instigates the "Undeploy" log in catalina.out, but the
application does now redeploy seamlessly).

Out of curiosity, is using a separate Context XML file the best way of
providing server-specific configuration to a tomcat web application? Not
using the standard webapps folder directly seems like bit of a work-around.
Although it looks like I'm now all set with this method, was I approaching
this config provision in the right way to start with?

Regards,

James

-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
Sent: Monday, March 08, 2010 5:01 PM
To: Tomcat Users List
Subject: RE: Best Practices for Deployment with separate Context XML file
(Tomcat 6.0.20)

> From: James Matthews [mailto:jxmatthews@gmail.com]
> Subject: RE: Best Practices for Deployment with separate Context XML
> file (Tomcat 6.0.20)

> <Context path="/Application"

Take out the path attribute - it's not allowed.

> docBase="/home/farthing/appservers/userapps">

The above should be "/home/farthing/appservers/userapps/Application.war".

 - 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.


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

---------------------------------------------------------------------
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: Best Practices for Deployment with separate Context XML file (Tomcat 6.0.20)

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: James Matthews [mailto:jxmatthews@gmail.com]
> Subject: RE: Best Practices for Deployment with separate Context XML
> file (Tomcat 6.0.20)

> <Context path="/Application"

Take out the path attribute - it's not allowed.

> docBase="/home/farthing/appservers/userapps">

The above should be "/home/farthing/appservers/userapps/Application.war".

 - 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.


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

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


RE: Best Practices for Deployment with separate Context XML file (Tomcat 6.0.20)

Posted by James Matthews <jx...@gmail.com>.
Hi Chuck,

I am attempting to follow your instructions, but I am not having much luck,
can I just check I am understanding you correctly.

1) I have created a folder with absolute path:
/home/farthing/appservers/userapps
2) In this folder I have placed my WAR file, Application.war
3) In /home/farthing/appservers/apache-tomcat-6.0.20/conf/Catalina/localhost
I have placed a file called Application.xml (contents of file below).

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/Application" docBase="/home/farthing/appservers/userapps">
	<Resource name="jdbc/postgres" auth="Container"
		type="javax.sql.DataSource"
driverClassName="org.postgresql.Driver"
		url="jdbc:postgresql://localhost:5432/XXXXXX"
		username="YYYYYY" password="ZZZZZZ" maxActive="20"
maxIdle="10"
		maxWait="-1"/>
</Context>

Each time I 'touch' Application.xml all I get in catalina.out is:

Mar 8, 2010 4:46:13 PM org.apache.catalina.startup.HostConfig checkResources
INFO: Undeploying context [/Application]

And the application does not deploy at any point.

Can you spot where I'm going wrong?

Many thanks,

James


-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
Sent: Monday, March 08, 2010 4:18 PM
To: Tomcat Users List
Subject: RE: Best Practices for Deployment with separate Context XML file
(Tomcat 6.0.20)

> From: James Matthews [mailto:jxmatthews@gmail.com]
> Subject: Best Practices for Deployment with separate Context XML file
> (Tomcat 6.0.20)
> 
> My question focuses on the best way to deploy a Web Application 
> to a running Tomcat instance when specifying the Context Container's
> configuration in a separate XML file in  $CATALINA_BASE/conf/
> [enginename]/[hostname]/

Don't keep the application in the <Host> appBase - locate it outside of
Tomcat's directory structure, and use the docBase attribute of the <Context>
element to tell Tomcat where to find it.  Replace the .war file at your
leisure, and then do a touch of the .xml file to trigger an application
redeployment.

 - 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.


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

---------------------------------------------------------------------
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: Best Practices for Deployment with separate Context XML file (Tomcat 6.0.20)

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: James Matthews [mailto:jxmatthews@gmail.com]
> Subject: Best Practices for Deployment with separate Context XML file
> (Tomcat 6.0.20)
> 
> My question focuses on the best way to deploy a Web Application 
> to a running Tomcat instance when specifying the Context Container's
> configuration in a separate XML file in  $CATALINA_BASE/conf/
> [enginename]/[hostname]/

Don't keep the application in the <Host> appBase - locate it outside of Tomcat's directory structure, and use the docBase attribute of the <Context> element to tell Tomcat where to find it.  Replace the .war file at your leisure, and then do a touch of the .xml file to trigger an application redeployment.

 - 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.


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

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