]> &project; Automatic Deployment - Use cases

This page defines the expected behaviour of the automatic deployer in many typical use cases. This is a complex area of Tomcat's functionality. While any difference between this document and Tomcat's behaviour is a bug, the fix may be to change this document, Tomcat's behaviour or both.

TermDescription
XML An XML configuration file located in the Host's configBase. It must contain a single <Context> element and may contain optional nested elements. It does not define an explicit docBase attribute. It represents a single web application. It is often referred to as a context.xml file.
XML+EW An XML configuration file located in the Host's configBase. It must contain a single <Context> element and may contain optional nested elements. It includes an explicit docBase attribute that points to an external WAR. It represents a single web application. It is often referred to as a context.xml file.
XML+ED An XML configuration file located in the Host's configBase. It must contain a single <Context> element and may contain optional nested elements. It includes an explicit docBase attribute that points to an external directory. It represents a single web application. It is often referred to as a context.xml file.
WAR A WAR file located in the Host's appBase. The WAR does not include an embedded context.xml file.
WAR+XML A WAR file located in the Host's appBase. The WAR does include an embedded context.xml file.
DIR A directory located in the Host's appBase. The directory does not include an embedded context.xml file.
DIR+XML A directory located in the Host's appBase. The directory does include an embedded context.xml file.
redeploy The Context object that represents the web application is destroyed and a new Context object is created. If present and permitted by the configuration, this new Context object is created by parsing the context.xml file. The web.xml file is parsed during the application start process. Any sessions stored in the standard Manager in the default configuration will not be persisted. Any requests to the web application during the redeploy will be handled as if the web application is not deployed.
reload The Context object that represents the web application is stopped and then started. The web.xml file is parsed during the application start process. Any sessions stored in the standard Manager in the default configuration will not be persisted. Any requests to the web application during the reload will be held until the reload completes at which point they will continue using the reloaded web application.

This section describes Tomcat's behaviour when the automatic deployment process discovers a new web application.

Starting artifact(s) Configuration Settings Result
deployXMLcopyXMLunpackWARs XMLWARDIRNotes
XML eithereithereither YNN1, 2, 3
XML+EW eithereitherfalse YNN1
XML+EW eithereithertrue YNY1
XML+ED eithereithereither YNN1, 2
WAR+XML falseeitherfalse NYN4
WAR+XML falseeithertrue NYY4
WAR+XML truefalsefalse NYN
WAR+XML truefalsetrue NYY
WAR+XML truetruefalse YYN
WAR+XML truetruetrue YYY
WAR eithereitherfalse NYN
WAR eithereithertrue NYY
DIR+XML falseeithereither NNY4
DIR+XML truefalseeither NNY
DIR+XML truetrueeither YNY
DIR falseeithereither NNY

This section describes Tomcat's behaviour when the automatic deployment process detects that a web application file has been deleted.

When a file is deleted or modified any redeploy resources that are listed after the modified/deleted resource are themselves deleted (and possibly re-created). The order of redeploy resources is:

  1. WAR
  2. DIR
  3. XML
  4. global resources

There are some exceptions to the deletion rule above:

In the following table:

Artifacts present Artifact removed Artifacts remaining
XMLWARDIR XMLWARDIRNotes
NNY DIR --N
NYN WAR -N-
NYY DIR -YR
NYY WAR -NN
YNN XML N--
YNY DIR N-N5
YNY XML XD-Y
YYN WAR NN-5
YYN XML XWY-
YYY DIR XWYR
YYY WAR NNN
YYY XML XWYY
YY (external)N WAR YN-3
YY (external)N XML NY (external)-6
YNY (external) DIR Y-N3
YNY (external) XML N-Y (external)6
YY (external)Y DIR YY (external)R
YY (external)Y WAR YNN3
YY (external)Y XML NY (external)N6

This section describes Tomcat's behaviour when the automatic deployment process detects that a web application file has been modified.

In the following table:

Artifacts present Artifact modified Artifacts remaining
XMLWARDIR XMLWARDIRAction
NNY DIR --MNone
NYN WAR -M-Redeploy
NYY DIR -YMNone
NYY WAR -MRRedeploy
YNN XML M--Redeploy
YNY DIR Y-MNone
YNY XML M-YRedeploy
YYN WAR YM-Reload
YYN XML MY-Redeploy
YYY DIR YYMNone
YYY WAR YMRReload
YYY XML MYYRedeploy
YY(external)N WAR YM(external)-Reload
YY(external)N XML MY(external)-Redeploy
YNY(external) DIR Y-M(external)None
YNY(external) XML M-Y(external)Redeploy
YY(external)Y DIR YY(external)MNone
YY(external)Y WAR YM(external)RReload
YY(external)Y XML MY(external)YRedeploy

This is treated as if the added file has been modified with the following additional actions:

  1. deployXML and copyXML are ignored since an XML file was discovered in the configBase.
  2. unpackWARs is ignored since there is no WAR file.
  3. The context will fail to start because there is no content in the expected docBase.
  4. The web application fails to deploy because it contains an embedded META-INF/context.xml, deployXML is false and an XML has not been provided in the configBase.
  5. The XML file is only deleted if copyXML is true and deployXML is true.
  6. Although the external resource is still present, the web application is fully undeployed as Tomcat has no knowledge of the external resource.