# Tomcat Upgrade from 9.x to 10.1.x (Linux)

This article outlines a systematic procedure for upgrading Apache Tomcat from version 9.0.x to 10.1.x on a Linux environment. Following these steps ensures application availability, minimizes downtime, and maintains configuration integrity. The process includes backing up existing configurations, upgrading Tomcat, reapplying critical settings, deploying application artifacts, and validating the environment after the upgrade.

## Prerequisites

Before beginning the upgrade, ensure the following:

* Administrator (root or sudo) privileges on the Linux server.
* Java 17 is installed and configured as the default Java runtime.
* Existing Tomcat installation is healthy and currently running without critical errors.
* Sufficient disk space for backups and the new installation package.
* Network access to download the latest Tomcat package or access to the pre-shared package provided by the OvalEdge team.

## Upgrade Procedure

1. **Stop Tomcat Services and Backup Existing Installation**
   * Stop the Tomcat service:

     ```bash
     sudo systemctl stop tomcat
     ```

     \
     \&#xNAN;*Sample Reference Screenshot:*

     <div align="left"><figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2Fbwkn2rCkiFYHUx4mgTzL%2F2.jpg?alt=media&#x26;token=e8d24a3f-09f5-48ce-8ad6-b9b023eae058" alt=""><figcaption></figcaption></figure></div>
   * Create a backup directory:

     ```bash
     mkdir -p /opt/tomcat_backup
     ```
   * Copy the current Tomcat installation to the backup location:

     ```bash
     cp -r /opt/tomcat /opt/tomcat_backup/tomcat_$(date +%F)
     ```

2. **Download the Latest Tomcat Release**
   * Official download site: [**Apache Tomcat Archives**](https://archive.apache.org/dist/tomcat/tomcat-10/)
   * Obtain Tomcat 10 Latest tarball:

     ```bash
     wget https://archive.apache.org/dist/tomcat/tomcat-10/v10.1.40/bin/apache-tomcat-10.1.40.tar.gz
     ```

     \
     \&#xNAN;*Sample Reference Screenshot:*

     <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FdnQVtFgkMFtxDrE2HzxW%2F3.jpg?alt=media&#x26;token=1765a504-d0b9-45fd-8f88-8e9b9f812e80" alt=""><figcaption></figcaption></figure>

3. **Extract Tomcat**
   * Extract the package into `/opt`:

     ```bash
     tar -xvf apache-tomcat-10.1.40.tar.gz -C /opt
     mv /opt/apache-tomcat-10.1.40 /opt/tomcat
     ```

     \
     \&#xNAN;*Sample Reference Screenshot:*

     <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FFTIfZyzSRADse3S2SyFv%2F4.jpg?alt=media&#x26;token=a86e0b1c-1633-449b-b81d-1d952f0bd1ac" alt=""><figcaption></figcaption></figure>

4. **Migrate setenv.sh**
   * Copy the setenv.sh file from the previous installation:

     ```bash
     cp /opt/tomcat_backup/tomcat_*/bin/setenv.sh /opt/tomcat/bin/
     ```

     \
     \&#xNAN;*Sample Reference Screenshot:*

     <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FSTKWTREaJrD9FZIn85g5%2F5.jpg?alt=media&#x26;token=99402e61-8158-46f6-b17b-0b7c4278e161" alt=""><figcaption></figcaption></figure>

     <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>For Release 72, additional parameters must be added to setenv.sh. Refer to the extprop configuration document or updates from the OvalEdge team for further information.</p></div>

5. **Deploy OvalEdge WAR and Third-Party JARs**
   * Obtain the OvalEdge Release 72 WAR file from the team.<br>

     <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FqOxSuZsGSMfeIR0SOBVw%2F6.jpg?alt=media&#x26;token=d9addd67-8f2d-4f6a-9b0b-15875c9f59e7" alt=""><figcaption></figcaption></figure>
   * Deploy the WAR file to the webapps directory:

     ```bash
     cp /path/to/ovaledge.war /opt/tomcat/webapps/
     ```
   * Replace third-party JARs:
     * Backup existing JARs:

       ```bash
       cp -r /opt/tomcat/third_party_jars /opt/tomcat_backup/third_party_jars_$(date +%F)
       ```
     * Replace 6.3.4 JARs with the Release 72 JARs provided by OvalEdge.<br>

6. **Configure server.xml**
   * Review and update `/opt/tomcat/conf/server.xml`:

     * Ensure startup/shutdown ports and SSL configurations are correctly set.
     * Enable compression by adding the connector:

     ```xml
     <!-- Comment out the default Connector -->
     <!--
     <Connector port="8080" protocol="HTTP/1.1"
                connectionTimeout="20000"
                redirectPort="8443" />
     -->

     <!-- Add Compression-enabled Connector -->
     <Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"
                compression="on" useSendfile="false"
                noCompressionUserAgents="gozilla, traviata"
                compressableMimeType="text/html,text/xml,text/plain,text/css,text/javascript,application/javascript"/>
     ```

     \
     \&#xNAN;*Sample Reference Screenshots:*

     <div align="left"><figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FlEIN1XhUVRNJRupYR7rL%2F7.jpg?alt=media&#x26;token=4001f676-24a5-4d15-a1f8-a6c6ec837180" alt=""><figcaption></figcaption></figure></div>

     <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FmAO9Pq4tx6P6XJVe2erE%2F8.jpg?alt=media&#x26;token=9ea4aa81-b58e-4c9e-883e-5a521d0f9b07" alt=""><figcaption></figcaption></figure>

7. **Configure context.xml**
   * Add caching to `/opt/tomcat/conf/context.xml`:

     ```xml
     <Resources cacheMaxSize="102400" />
     ```

     \
     \&#xNAN;*Sample Reference Screenshot:*

     <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FoOzvcihbcfgnprcy33TR%2F9.jpg?alt=media&#x26;token=2aa9aeef-0954-46d7-81e1-91a4e268e108" alt=""><figcaption></figcaption></figure>
   * Save and close the file.<br>

8. **Update Tomcat Service Configuration**
   * Edit the Tomcat systemd service file (`/etc/systemd/system/tomcat.service`) to reflect the new installation path (`/opt/tomcat`).
   * Reload systemd to apply changes:

     ```bash
     sudo systemctl daemon-reload
     ```

     \
     \&#xNAN;*Sample Reference Screenshot:*

     <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2Fl837jTZkiLgbISuO9LRD%2F10.jpg?alt=media&#x26;token=bad849fe-6114-4a61-8f48-707378326415" alt=""><figcaption></figcaption></figure>

9. **Start Tomcat Service**
   * Start Tomcat:

     ```bash
     sudo systemctl start tomcat
     ```

     \
     \&#xNAN;*Sample Reference Screenshot:*

     <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FpgL2wJvHPRpSCE456Vb8%2F11.jpg?alt=media&#x26;token=f4c456e2-797a-41a7-895c-8469a1518145" alt=""><figcaption></figcaption></figure>
   * Enable auto-start at boot:

     ```bash
     sudo systemctl enable tomcat
     ```

### Testing and Verification

* Access the application via browser at the configured URL.
* Validate that the OvalEdge application functions as expected.
* Monitor Tomcat logs for errors or warnings (`logs/catalina.out`, `logs/catalina.YYYY-MM-DD.log`, etc.):

  ```bash
  tail -f /opt/tomcat/logs/catalina.out
  ```

  \
  \&#xNAN;*Sample Reference Screenshot:*

  <div align="left"><figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FgTmIeZnUQMy0n4KKu7Wa%2F12.jpg?alt=media&#x26;token=97b6faca-0b73-41e3-803f-36cbe87c18fb" alt=""><figcaption></figcaption></figure></div>
* Check rotated logs for startup errors:

  ```bash
  /opt/tomcat/logs/catalina.YYYY-MM-DD.log
  ```

### Rollback Procedure

* If issues occur during or after the upgrade:
  * Stop the new Tomcat service:

    ```bash
    sudo systemctl stop tomcat
    ```
  * Restore the previous Tomcat backup:

    ```bash
    rm -rf /opt/tomcat
    cp -r /opt/tomcat_backup/tomcat_<backup-date> /opt/tomcat
    ```
  * Reload systemd and restart Tomcat:

    ```bash
    sudo systemctl daemon-reload
    sudo systemctl start tomcat
    ```
  * Validate application functionality using the restored version.

***

Copyright © 2025, OvalEdge LLC, Peachtree Corners, GA, USA.
