Apache Tomcat 9 (9.0.73) – Tomcat Web Application Deployment

Finally, web application deployment can be accomplished using Tomcat Client Deployer. This is a package that can be used to validate, compile, compress to . WAR, and deploy web applications to production or development Tomcat servers. It should be noted that this function uses Tomcat Manager and as such the target Tomcat server must be running.

It is assumed that the user will be familiar with Apache Ant to use the TCD. Apache Ant is a scripted build tool. The TCD comes prepackaged with a build script to use. Only a modest understanding of Apache Ant is required (installation as listed earlier on this page and familiarity with using the operating system command shell and setting environment variables).

The TCD includes Ant tasks, the Jasper page compiler for JSP compilation before deployment, as well as a task that validates the context descriptor of the web application. The validator task (org.apache.catalina.ant.ValidatorTask class) allows only one parameter: the base path of an exploited web application.

The TCD uses an exploited web application as input (see list of properties used below). A Web application that is deployed programmatically with the deployer can include a context descriptor in /META-INF/context.xml.

The TCD includes a ready-to-use Ant script, with the following targets:

compile

  • (default): Compile and validate the web application. This can be used independently and does not require a running Tomcat server. The compiled application will only run on the associated X.Y.Z server version of Tomcat and is not guaranteed to work on another version of Tomcat, as the code generated by Jasper depends on its runtime component. It should also be noted that this target will also automatically compile any Java source files located in the /WEB-INF/classes folder of the web application.
  • deploy: Deploy a web application (compiled or not) to a Tomcat server.
  • undeploy: Undeploy
  • a web application start: Start reloading the web application:

  • Reload
  • the web application stop

  • : stop the web
  • application

To configure the deployment, create a file named deployer.properties in the root of the TCD installation directory. In this file, add the following name=value pairs per line: In addition,

you will need to ensure that

a user has been configured for the target Tomcat Administrator (which uses TCD), otherwise the TCD will not authenticate with Tomcat Manager and the deployment will fail. To do this, refer to the Tomcat Administrator page.

build: The build folder used will be, by default, ${build}/webapp/${path} (${build},

  • by default, it points to ${basedir}/build). After the build target finishes running, the Web application . WAR will be located at ${build}/webapp/${path}.war.
  • webapp: The directory containing the exploited web application to be compiled and validated. By default, the folder is myapp.
  • path: Deployed context path of
  • the web application, by default /myapp. url: Absolute URL of the Tomcat Manager web application

  • of a running Tomcat server, which will be used to deploy and undeploy the web application. By default, the deployer will attempt to access a Tomcat instance running on localhost, on http://localhost:8080/manager/text.
  • username: Tomcat Manager username

  • (user must have an administrator script role) password: Tomcat Manager password
  • .