Security and compliance are top priorities for any IT team. Because Tomcat can be exposed to the internet, it’s important that it stays up to date. Previously, checking for updates and upgrading Tomcat was a very time consuming process that needed to happen regularly.
To eliminate this administrative overhead, mrc now provides an automated point-release upgrade script. Instead of manually downloading and installing individual Tomcat files, you can run a simple script that automatically checks for the latest minor revision, downloads it, and securely updates your environment.
How the Automated Script Works
This script is designed to upgrade an existing Apache Tomcat installation to the latest point release of the same major version (for example, Tomcat 10.1.40 → 10.1.52). It will never upgrade your server to a new major version (e.g., moving from Tomcat 9 to 10).
When executed, the script automatically handles the entire process:
- Detects your installed Tomcat version and downloads the newest matching release directly from Apache (checksum-verified).
- Stops the Tomcat service.
- Backs up your existing lib, bin, and conf directories.
- Replaces the Tomcat program files.
- Restarts the Tomcat service and verifies it is running.
Your configuration is never modified. The script strictly preserves your conf directory (including server.xml), webapps, setenv files, and any custom JARs (like JDBC drivers) in your lib folder.
Windows
1. Download the Utility: Download the automated upgrade package to your server here: Download Tomcat Upgrade Utility (.zip).
2. Extract the Package: Extract the contents of the ZIP file directly into your root m-power directory. Once extracted, the upgrade-tomcat folder must sit directly next to your tomcat folder inside m-power:
m-power/
tomcat/ <- The server being upgraded
upgrade-tomcat/ <- Extracted script directory
3. Run the Script: The easiest method on Windows is to run the batch file directly:
- Open File Explorer and navigate to
\m-power\upgrade-tomcat\. - Right-click
upgrade-tomcat.batand select “Run as Administrator”. - The script will execute the upgrade and keep the command window open so you can read the final result. (Alternatively, you can run
upgrade-tomcat.batfrom an elevated Command Prompt or PowerShell).
Running With Arguments (Advanced): Pass arguments to the execute script (only needed when the defaults don’t apply):
upgrade-tomcat.bat -CatalinaHome "D:\somewhere\tomcat" -ServiceName Tomcat10 -HttpPort 8012
| Argument | Default when omitted |
-CatalinaHome | The sibling tomcat folder next to this script folder. |
-ServiceName | Auto-detected: the tomcat* Windows service whose install path matches the Tomcat folder being upgraded. If none matches, shutdown.bat/startup.bat are used. |
-HttpPort | Read from that Tomcat’s own conf\server.xml (used only to verify stop/start). |
Linux
1. Download the Utility: Open your terminal and navigate to your m-power directory. Use wget to download the upgrade utility directly to the server:
cd /mrc/development/m-power
wget https://mrc-productivity.com/products/tomcat/upgrade-tomcat.zip
2. Extract the Package: Extract the contents so the upgrade-tomcat directory sits directly next to your tomcat folder:
jar -xf upgrade-tomcat.zip
3. Run the Script: Navigate into the newly extracted directory, make the script executable (one-time change), and run it:
cd upgrade-tomcat
chmod +x upgrade-tomcat.sh
./upgrade-tomcat.sh
Running With Arguments (Advanced): Pass arguments to the execute script (only needed when the defaults don’t apply):
./upgrade-tomcat.sh -c /opt/somewhere/tomcat -s tomcat.service -p 8012
| Argument | Default when omitted |
-c (catalina home) | The sibling tomcat folder next to this script folder. |
-s (systemd service) | None — shutdown.sh/startup.sh are used, run as the Tomcat folder’s owner. If -s is given, the unit file must reference the same Tomcat folder. |
-p (HTTP port) | Read from Tomcat’s own conf/server.xml (used only to verify stop/start). |
Good to Know
- Do Not Stop Tomcat: Tomcat is stopped and restarted automatically by the script. Do not stop the service yourself beforehand. Expect a brief outage while the files are replaced.
- Internet Access Required: The server must have internet access to dlcdn.apache.org to download the new Tomcat release.
- Backups: A timestamped backup folder (e.g., backup-<old version>-<date>) is left inside the Tomcat directory after completion. You can safely delete this once you verify everything is running smoothly.
- Up-to-Date Systems: If your installation is already on the latest minor release, the script will simply exit without changing anything.
Automating the Upgrade Process
While this script is easy to run manually, you can also schedule it to run on a regular basis using your operating system’s built-in task management tools (such as Windows Task Scheduler or a Linux cron job). To set this up, simply configure your scheduler to execute the appropriate file for your environment:
- Windows: upgrade-tomcat.bat
- Linux: upgrade-tomcat.sh