Automatically updating Java and Apache Tomcat

This script (Update-WebOfficeMiddleware.ps1) automatically updates the software that WebOffice runs on - the Java version (JDK) and Apache Tomcat - to the respective latest minor version. WebOffice itself and your projects are not changed in the process.

 

The script only changes the program files of Java and Apache Tomcat themselves. Any web application running under Apache Tomcat - whether located in the webapps folder or referenced from another location via a context file - remains completely untouched. This is true regardless of whether it is a WebOffice application or not: the script can therefore also be used on a Apache Tomcat instance that, besides WebOffice, also runs other, unrelated web applications.

 

The script never switches to a new major version (for example from Java 21 to Java 22) - only to the latest minor version of the major version that is already installed (for example from Java 21.0.13 to 21.0.13.1). Jumping to a new major version must still be planned and carried out manually and deliberately.

 

Before making any change, the script automatically checks whether an update is even available, downloads the new version directly from the official download page, and verifies the file against its checksum before using it. Only then is Apache Tomcat briefly stopped, the new version installed, and Apache Tomcat started again. The script then checks for itself whether everything works (version check, certificate store, web request) - if anything fails, the script automatically rolls the change back.

 

icon_cross-reference

This script automates exactly the manual steps described in the chapters Java and Maintaining Apache Tomcat (download, installation, adjusting the Java link in the Apache Tomcat service, restart) - including the restart of the WebOffice FTS-Index service mentioned there, if it uses the same Java version.

 

Prerequisites:

•A Windows server on which WebOffice runs with Apache Tomcat (as a Windows service).

•The script must be run with administrator rights (it will prompt for these itself if needed).

•Internet access to the official download pages of Java (Eclipse Adoptium) and Apache Tomcat. Without internet access, the required file can also be placed manually in a folder next to the script (see parameter -OfflinePackageDir below).

•The script is designed for all WebOffice versions that use either Java 11 with Apache Tomcat 9, or Java 21 with Apache Tomcat 11 - meaning it can be used starting with WebOffice 10.9 R3 and all later versions.

 

icon_comment

Recommendation: Before a real run, create a snapshot or a backup of the server, as you would before any software update on a production system.

 

Usage:

1.Always run with the parameter -DryRun first. This mode does not change anything on the server - it only shows what the script would do, including any warnings you should review beforehand.

2.Carefully read the result of the dry run, especially any WARN lines.

3.Only once the result looks fine, run the script again without -DryRun for the real run. Before actually making the change, the script explicitly asks for confirmation once more (unless running in unattended mode, see parameter -Unattended below).

 

icon_comment

Do not click into the console window while the script is running. A click starts Windows' text-selection mode and pauses the script (the window title then starts with "Select..."). Press Esc to continue.

 

Available parameters:

Parameter

Meaning

-DryRun

Preview only, nothing is changed. Always use this first.

-Unattended

For automated use (for example via the Windows Task Scheduler): no prompts, no waiting for confirmation.

-UpdateScope

What should be updated: All (default, Java and Apache Tomcat), JdkOnly (Java only) or TomcatOnly (Apache Tomcat only).

-UninstallOldJdk

Whether the old Java version is automatically removed after a successful update. Default: $true. See the note below.

-ServerXmlMode

How custom changes in the Apache Tomcat configuration file server.xml are handled: Merge (default, custom changes are kept and merged with the new default file), KeepOld or UseNewDefault.

-LogRetentionDays

How many days old log files are kept before being automatically deleted. Default: 30.

-OfflinePackageDir

Folder containing an installation file (plus checksum file) already downloaded manually, for servers without internet access.

-TomcatService

Only needed when more than one Apache Tomcat service is found on the server: names the exact one to update by its Windows service name (for example Tomcat11) - every other instance found is left completely untouched. Without this parameter in that situation, the script asks interactively; with -Unattended and no -TomcatService, it stops with an error instead of guessing.

 

The accompanying launcher (Update-WebOfficeMiddleware.cmd) also accepts /dryrun and /unattended in this notation.

 

Important note: once the old Java version has been removed, there is no automatic way back

As long as the run itself has not yet completed successfully, the script automatically rolls everything back on any error - in that case the old Java version is also left completely intact.

 

icon_comment

Only after the run is considered successfully completed is the previous Java version automatically removed (unless -UninstallOldJdk was set to $false). From this point on, there is no automatic way "back" to the old version - switching back later would only be possible through a manual reinstallation of the old Java version.

 

Anyone who wants extra safety can use -UninstallOldJdk $false: the old version is then left on the server and can be removed manually later.

 

Disclaimer:

This script is an automated technical aid, not a guarantee. VertiGIS accepts no liability for the outcome of running this script or for decisions based on it. Reviewing the result and deciding whether to proceed is the responsibility of the server administrator.

 

Download:

The current version of the script is available at the following link: Update_WebOffice_Middleware.zip. This link will remain unchanged for future versions.

 

icon_cross-reference

Regularly updating Java and Apache Tomcat is the foundation of secure operation. For further measures, see the chapter Securing WebOffice — Recommendations for Production Use.