Enable autoDeploy on context Tomcat 7

BRabbit27 picture BRabbit27 · Apr 4, 2012 · Viewed 12k times · Source

I've been reading that enabling the autoDeploy option will cause to hot deploy an app when putting a new war file. If I just want to set autoDeploy in just one app and not in the entire server I'm supposed to enable it in <app>/META-INF/context.xml am I right?

If so, the file should look like which one of the following?

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/TestApp">
    <autoDeploy>true</autoDeploy>
</Context>

or

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/SRC_RichFaces" autoDeploy="true">
</Context>

When I try either, there's a warning [SetContextPropertiesRule]{Context} Setting property 'autoDeploy' to 'true' did not find a matching property.

Any advice?

UPDATE

Sorry for the inconvenience, I misunderstood the documentation. I have to enable the <Host> attribute autoDeploy.

So I should have in the context.xml something like

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/TestApp"/>
<Host autoDeploy="true"/>

am I right?

Answer

Mark Thomas picture Mark Thomas · Apr 5, 2012

You can not do what you are trying to do. autoDeploy is only configurable per Host, not per Context.

The closest you could get is to enable autoDeploy for the Host's appBase and place the apps where you want autoDeploy enabled in the appBase and the other applications outside the appBase. These would then need to be deployed by adding context.xml elements under $CATALINA_BASE/Catalina/localhost

E.g. to deploy my app this way you'd create the file:
$CATALINA_BASE/Catalina/localhost/myapp.xml
with the contents:

<Context docBase="/absolute/path/to/myapp.war" >