The Apache Tomcat Servlet/JSP Container

Apache Tomcat 7

Version 7.0.67, Dec 7 2015
Apache Logo

Links

Top Level Elements

Executors

Connectors

Containers

Nested Components

Cluster Elements

web.xml

Other

Automatic Deployment - Use cases

Table of Contents
Introduction

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.

Key
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.
New files

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
Deleted files

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:

  • global resources are never deleted
  • external resources are never deleted
  • if the WAR or DIR has been modified then the XML file is only deleted if copyXML is true and deployXML is true

In the following table:

  • '-' means "unchanged from not present". i.e. the artifact wasn't present before the change and isn't present after it either. '-' rather than 'N' is used to focus attention on what changes.
  • 'R' means that the directory is re-created by expanding the WAR file. This will only happen if unpackWARs is true.
  • 'XW' means that the if the WAR contains a META-INF/context.xml file it will be extracted and placed in the Host's configBase. This only happens if copyXML is true and deployXML is true.
  • 'XD' means that the if the directory contains a META-INF/context.xml file it will be copied to the Host's configBase. This only happens if copyXML is true and deployXML is true.
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
Modified files

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

In the following table:

  • '-' means "unchanged from not present". i.e. the artifact wasn't present before the change and isn't present after it either. '-' rather than 'N' is used to focus attention on what changes.
  • 'M' means that the artifact has been modified.
  • 'R' means that the directory is re-created by expanding the WAR file. This will only happen if unpackWARs is true.
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 YMYReload
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
Added files

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

  • If a WAR is added, any DIR is removed and may be recreated depending on unpackWARs.
  • If an XML file is added that refers to an external docBase any WAR or DIR in the appBase will be removed. The DIR may be recreated if the external resource is a WAR and unpackWARs is true.
  • If a DIR is added when a WAR already exists and unpackWARs is false, the DIR will be ignored but a warning will be logged when the DIR is first detected. If the WAR is removed, the DIR will be left and may be deployed via automatic deployment.
  • If a WAR is added to the appBase when an external WAR already exists, the WAR in the appBase will be ignored but a warning will be logged when the WAR in the appBase is first detected. If the external WAR is removed, the WAR in the appBase will be left and may be deployed via automatic deployment.
  • If an XML file is added to the META-INF directory of an application deployed from that DIR, the application will always be redeployed. The result will be the same as for a new deployment.
Notes
  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.
Comments

Notice: This comments section collects your suggestions on improving documentation for Apache Tomcat.

If you have trouble and need help, read Find Help page and ask your question on the tomcat-users mailing list. Do not ask such questions here. This is not a Q&A section.

The Apache Comments System is explained here. Comments may be removed by our moderators if they are either implemented or considered invalid/off-topic.


Copyright © 1999-2015, Apache Software Foundation