Hot Deployment

If you need to deploy and undeploy your webapp without needing to restart the Tomcat JVM in order for the deployment and undeployment to take effect, you want "Hot Deployment." In this section, we focus on local filesystem hot deployment, where everything happens on one machine, as opposed to remote hot deployment, where you hot deploy a webapp from one machine to another machine running Tomcat. For remote hot deployment, you should use the Manager webapp, detailed later in this chapter.

In the "Hosts" section, earlier in this chapter, we showed you how to configure your Host for hot deployment (explicitly set autoDeploy="true" and deployOnStartup= "false" on your Host). Once you have that set, you may hot deploy your webapps into that Host in the following ways:

  • Create a <Context> container XML element in your server.xml file, nested within the Host that has hot deployment enabled.

  • Copy your web application's WAR file into your hot deployment-enabled Host's appBase and Tomcat will deploy it and start it up.

  • Create a context XML fragment file that points to the webapp's unpacked directory or WAR file and drop the context XML fragment file into the CATALINA_HOME/conf/[EngineName]/[HostName]/ directory.

If you're not placing a context XML fragment file in the CATALINA_HOME/conf/[EngineName]/[HostName]/ directory, and your webapp contains a META-INF/context.xml file, that context.xml file will be read and used by Tomcat (again, make sure you do not set deployXML="false"

Get Tomcat: The Definitive Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.