Migrate the Applications and Configure the Source

Migrate the Apache Tomcat application WAR files and configure the datasource to point to the new database in the cloud.

Migrate the Apache Tomcat Applications

Migrate the Apache Tomcat application WAR files to the target Tomcat server.

  1. Gather the Tomcat servers IP addresses from the Terraform output.
  2. Set the PUBLIC IP of the bastion server.
    export BASTION_IP=Bastion Public IP
  3. Set the PRIVATE IP of the Tomcat server.
    export TOMCAT_IP=Private IP of the Tomcat server
  4. Copy the application WAR file over to the target Tomcat server.
    # go to the location of the tomcat webapps folder
    cd /usr/local/tomcat/webapps/
    # scp the war files to the target tomcat server.
    scp -o ProxyCommand="ssh -W %h:%p
    opc@${BASTION_IP}” application.war opc@${TOMCAT_IP}:~/
  5. SSH to the target Tomcat server through the bastion host.
    ssh -o ProxyCommand="ssh -W %h:%p
          opc@${BASTION_IP}” opc@${TOMCAT_IP}
  6. Copy the file to the deployment folder
    sudo cp application.war /var/lib/tomcat/webapps/
  7. Verify that the deployment happened as expected.
    cd /var/lib/tomcat/webapps/
    ls -lh
    When the war file is deployed, a new folder called application is created in the directory. It might take several seconds to deploy, so if you don't see the folder at first, try the ls -lh command again.

Configure the Datasource

Deploy and configure the datasource for each Apache Tomcat server.

  1. Open the server.xml file in the /etc/tomcat/ directory for editing.
  2. Add the following section within the existing GlobalNamingResources section.

    Make sure to replace USER_NAME, CONNECTION_NAME, USER_PASSWORD, and ATP_DB_NAME with your information in the connection.

    <Resource name="jdbc/CONNECTION_NAME"
          global="jdbc/CONNECTION_NAME"
          auth="Container"
          type="javax.sql.DataSource"
          username="USERNAME"
          password="USER_PASSWORD"
          driverClassName="oracle.jdbc.OracleDriver"
          description="My DB"
    url="jdbc:oracle:thin:@ATP_DB_NAME_tp?TNS_ADMIN=/etc/tomcat/wallet"
          maxActive="15"
          maxIdle="3"/>
  3. Save the file.
  4. Open the context.xml file for editing.
  5. Add the following section inside the Context / tag to add the connection:

    If your application contains its own context.xml file, this step might not be necessary.

    <ResourceLink name="jdbc/CONNECTION_NAME"
        global="jdbc/CONNECTION_NAME"
        type="javax.sql.DataSource"/>
  6. Restart Tomcat.
    sudo systemctl restart tomcat
  7. Verify that the application is correctly deployed. On the individual server, use the following:
    curl http://localhost:8080/Application_name
  8. Repeat Steps 1 through 7 to configure the deployment and datasource for each Tomcat server.
  9. To verify that the application is served by the load balancer, get the load balancer public IP from the Terraform output, then go to http://LOAD_BALANCER_IP/Application_name/.