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. Hover over a configuration item and click Menu button, and depending on where Tomcat running, select one of the following options:

    • If Tomcat is running on the same computer as XL 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.

  6. In the Name field, enter a unique name for the server.

  7. 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.

  8. In the Start Command field, enter the home directory, followed by the OS-specific command to start Tomcat. For example:

    • service tomcat8 start on Unix.
    • net start tomcat8 on Microsoft Windows.

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

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

    • service tomcat8 stop on Unix.
    • net stop tomcat8 on Microsoft Windows.
  10. In the Start Wait Time field, enter the number of seconds that XL Deploy should wait after executing the start command and before continuing with the deployment plan.

  11. In the Stop Wait Time field, enter the number of seconds that XL 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.

  12. Click Save to create the server.

    Create server

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

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

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

  16. Click Save to create the virtual host.

    Create virtual host

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

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

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

  20. Click Save to create the environment.

Create server

Step 2 - Import the sample application

XL Deploy includes two versions of a sample application called PetClinic-ear, that is already packaged in the XL 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, XL 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.