Skip to main content
Version: Deploy 23.1

Deploy an app on Apache Tomcat

This tutorial describes how to deploy an application on Apache Tomcat.

It assumes you have the Tomcat plugin installed.

Required Tomcat setup

Tomcat must be configured to run in the background. On Unix, Tomcat should be installed as a daemon or the Tomcat startup script should start Tomcat in the background. On Windows, you must install Tomcat as a service.

For more information on running Tomcat in the background, see documentation for your version of Tomcat.

Step 1 - Create an environment

An environment is a grouping of infrastructure and middleware items such as hosts, servers, clusters, and so on. An environment is used as the target of a deployment, enabling you to map deployables to members of the environment.

To create an environment:

  1. In the top navigation bar, click Explorer.

  2. From the Library navigation pane, hover over Infrastructure, and then click Menu button. Based on where Tomcat is running, select one of the following options:

    • If Tomcat is running on the same computer as Deploy, choose new>overthere>LocalHost.
    • If Tomcat is running on a Unix-based operating system, choose new>overthere>SshHost.
    • If Tomcat is Running on Microsoft Windows, choose new>overthere>CifsHost.
  3. In the name field, enter a unique name for the connection.

  4. Choose an operating system and click Save to create connection.

    Create connection

  5. On the connection you created, click Menu button, then select new > tomcat > Server

note

If you do not see the Tomcat option in the menu, verify that the Tomcat plugin is installed.

  1. In the Name field, enter a unique name for the server.
  2. In the Home field, enter Tomcat home directory. For example, /opt/apache-tomcat-8.0.9/ on Unix, or C:\Program Files\Tomcat\ on Microsoft Windows.
  3. In the Start Command field, enter the home directory, followed by the OS-specific command to start Tomcat. For example:
    • ./bin/startup.sh on Unix.

    • /bin/startup.bat on Microsoft Windows.

note

Deploy expects the Tomcat start command to return and leave Tomcat running. If the start command does not return, Deploy will not complete a deployment to Tomcat.

  1. In the Stop Command field, enter the home directory, followed by the 0S-specific command to stop Tomcat. For example:

    • ./bin/shutdown.sh on Unix.
    • /bin/shutdown.bat on Microsoft Windows.
  2. In the Start Wait Time field, enter the number of seconds that Deploy should wait after executing the start command and before continuing with the deployment plan.

  3. In the Stop Wait Time field, enter the number of seconds that Deploy should wait after executing the stop command and before continuing with the deployment plan.

note

If your startup and shutdown scripts only return after the server has fully started or stopped, you can set the wait time to 0.

  1. Click Save to create the server.

    Create server

  2. To start the Tomcat server, do the following:

    1. Hover over the server you created, click Menu button, and then click Start Server > Execute. The Start Server execution plan page displays the status of Start Server command. .
  3. To stop the Tomcat server, do the following:

  4. Hover over the server you created, click Menu button, and then click Stop Server > Execute. The Start Server execution plan page displays the status of Stop Server command.

  5. To add a Tomcat virtual host, hover over the server you created, click Menu button, then select new > tomcat > VirtualHost.

  6. In the Name field, enter a name for the virtual host.

  7. Optionally, change the App Base and Host Name. The defaults are webapps and localhost.

  8. Click Save to create the virtual host.

    Create virtual host

  9. Hover over Environments, click Menu button, and select new > Environment.

  10. In the Name field, enter a unique name for the environment.

  11. From the Containers list, select the tomcat virtual host that you created.

  12. Click Save to create the environment.

Create server

Step 2 - Import the sample application

Deploy includes two versions of a sample application called PetClinic-ear, that is already packaged in the Deploy deployment package format (DAR).

To import the PetClinic-ear/1.0 sample application, follow the steps described in Import a package instructions.

Step 3 - Deploy the sample application

To deploy the sample application, follow the steps described in Deploy an application.

If the deployment succeeds, the state of the deployment plan is EXECUTED.

Successful deployment

If the deployment fails, click the failed step to see information about the failure. In some cases, you can correct the error and try again. For example, in the deployment shown below, Deploy could not stop the Tomcat server because the shutdown script is set to /opt/apache-tomcat-8.0.1/bin/startup. You should abort the deployment and correct the Stop Command in the Tomcat server configuration in the Repository, then try the deployment again.

Failed deployment

Verify the deployment

To verify the deployment, go to http://IP:8080/petclinic, where IP is the IP address of the Tomcat server.

Get help

To ask questions and connect with other users, visit our forums.