Académique Documents
Professionnel Documents
Culture Documents
Startup Deployment
Also knowns as folder deployment, startup deployment is the easiest way to deploying a
web application to your server.
To have Tomcat deploy an application automatically when it starts, simple copy either an
uncompressed web application (also known as an "exploded" application) or a
compressed application, or WAR, to the appBase folder specified in your Host
configuration.
When Tomcat starts, it will deploy all applications in the appBase, in the following order:
1. Applications defined by Context elements in either
"$CATALINA_BASE/conf/server.xml" (discouraged),
"$CATALINA_BASE/conf/[EngineName]/[HostName]/[ApplicationName].xml",
"or $CATALINA_BASE/webapps/[ApplicationName]/META-INF/context.xml"
2. Uncompressed (exploded) applications located in the appBase without Context
Descriptors.
3. docBase applications that are compressed in WAR files, along with WARs
associated with an existing application, which will be used to automatically
redeploy the application.
To deploy a new application, Tomcat copies its directory structure to the relevant context
path in its base webapps folder, creating directories as needed. If the application provides
Hot Deployment
The big downfall of startup deployment is that it requires a full server restart to make any
changes to the application, or deploy new applications, even if the application doesn't
have any elements that would require a restart for it to function.
To remedy this situation, Tomcat provides a number of "hot deployment" options, which
simply means that any deployments, redeployments, and adjustments to applications are
made while the server is still running, rather than requiring it to stop.
There are a number of ways to use hot deployment with Tomcat. In this section, we'll go
over the most common: Host autoDeploy, the Tomcat Manager, and the Tomcat Client
Deployer.
Host autoDeploy
The most recent versions of Tomcat support a number of hot deployment features right
out of the box. These features are enabled on a per-Host basis, by setting the
"autoDeploy" attribute to "true".
Here are some of the things you can do once you've enabled hot deployment:
For a complete list of autoDeploy-enabled hot deploy features, visit the Apache project
website.
Deployment with Tomcat Manager
The Tomcat Manager is a lightweight administrative tool included with all standard
distributions of Apache Tomcat, that provides a wide variety of deployment
functionalities, including a number of hot deployment commands.
Manager commands are sent in a standard URI format, as follows:
http://[host]:[port]/manager/[command]?[parameters]
Using the Manager, you can deploy an application to a running Tomcat server from pretty
much anywhere - there are usages for remote deployment, local path deployment,
deployment from WAR, deployment from the appBase, and even deployment by calling a
context.xml file that provides a docBase path.
Manager can also remotely reload, undeploy (careful, this means delete), start, and stop
applications.
To make sure that Tomcat is secure out of the box, Manager and its features are disabled
by default, and it takes more than a little wrangling to get it up and running.
For more information about using the Manager application on your server, including a list
of commands and some example usages, please check out our helpful Tomcat Manager
Guide.
Deployment with the Tomcat Client Deployer
The Tomcat Client Deployer (TCD) is a multi-component Java package that uses a
variety of technologies to validate, compile, compress, and deploy your web applications.
TCD is basically a bundle of Ant tasks that execute functions of the Jasper JSP Engine,
JDK, and Catalina engine (including the Tomcat Manager) to quickly move applications
from your hard drive to your running Tomcat server.
TCD is not included with standard distributions of Tomcat. You can download it
separately from the Tomcat project site. You can decompress it anywhere you want; it
doesn't need to be in a Tomcat directory. If you haven't installed it already, you'll also
need to download and install Apache Ant in order for TCD to run. Note that a
configured, running instance of the Tomcat Manager application is required for TCD to
work.
To deploy an application using TCD, you will need to create and edit a file named
"deployer.properties", which should be located in the root directory of the TCD package.
This file will look something like this, substituting [values] and {variables}:
build=${build}/webapp/${path}
webapp=[path/to/target/exploded/application]
path=[DesiredContextPath]
url=[http://[host]:[port]/path/to/manager/webapp]
username=[UserWithManagerRole]
password=[TomcatManagerPassword]
Once you have configured this file, run TCD with the included Ant script. The default
target, "compile", will validate and compile the web application as a WAR file at the
specified "build" location. Other targets with self-explanatory features include deploy,
undeploy, start, reload, and stop.