Table of Contents

Server updates - Apache Tomcat updates

This tutorial shows how you can update the Apache Tomcat in your CzechIdM deployment. In this particular howto we are updating from Tomcat 8.5.11 to Tomcat 8.5.50. If necessary, adjust performed commands to your needs.

Things to consider

Apache Tomcat application container is a part of the CzechIdM stack and its update requires some service downtime. When done correctly, this downtime can be a matter of minutes - but you shall always plan for the worst. :) As always, there is a number of things to consider.

Performing the Tomcat update

Following list can be used as a basis for the maintenance checklist. Feel free to customize it to better suit your needs. You can safely perform almost all steps of this guide on a running system and then just switch the Tomcat distribution.

This howto expects you to have Tomcat installed according to our official installation howto.
  1. Download new tomcat binaries from the web, in our case this is a 8.5.50 version.
  2. Unpack new Tomcat into /opt/tomcat alongside existing installation.
  3. Set correct permissions for the new Tomcat (they are similar to those you ran during the clean installation of Tomcat).
    cd /opt/tomcat/apache-tomcat-8.5.50
    chmod -vR o+rX ./
    chgrp -R tomcat conf/ bin/ lib/
    chmod g+rwx conf/
    chmod g+r conf/*
    chown -R tomcat webapps/ work/ temp/ logs/
    cd /opt/tomcat
    chgrp tomcat apache-tomcat-8.5.50/
  4. Customize / copy over configuration from previous Tomcat installation. This means at least:
    1. Adjusting new server.xml - disabling shutdown port and tying AJP (8009/tcp) and HTTP (8080/tcp) ports to localhost.
    2. Remove contens of new Tomcat's webapps/ directory.
    3. To perform these steps, see installation guide for details.
  5. Link-in the PostgreSQL JDBC driver.
    cd /opt/tomcat/apache-tomcat-8.5.50/lib/
    ln -sv /usr/share/java/postgresql-jdbc.jar
  6. Create / copy over the setenv.sh file from the old Tomcat's bin/ directory to the bin/ of the new Tomcat. Make sure the file has correct permissions.
  7. Copy over the idm.war file from the old Tomcat's webapps/ directory to the webapps/ of the new Tomcat.
  8. THE DOWNTIME STARTS HERE.
  9. Disconnect all users, kill LRT, etc. and start the maintenance.
  10. Disable monitoring system notifications.
  11. Switch to new Tomcat.
    systemctl stop tomcat
    # here you should make database backup; you should not need it at all, just to be safe
    cd /opt/tomcat
    unlink current
    ln -s apache-tomcat-8.5.50 current
    systemctl start tomcat
  12. Check logs to see if the application started properly.
  13. Perform testing with selected use-cases, test connected end systems, etc.
  14. If you try to connect through Apache HTTPd and it shows "bad gateway" error, give the HTTPd a reload/restart (or just wait a while longer). The web server has a heartbeat interval to check if upstream (i.e. Tomcat) lives or not and simply thinks the application container is not running yet.
  15. THE DOWNTIME ENDS HERE.
  16. Enable monitoring system notifications.
  17. (After a week or so, if everything runs fine.) Clean up the previous installation of Tomcat, move application logs you want to preserve to a new destination.

Resolving issues

Returning back from an unsuccessful update means just swapping back to the old Tomcat installation. It requires some downtime. (In this example, we are returning to the 8.5.11 version of Tomcat.)

  1. THE DOWNTIME STARTS HERE.
  2. Disconnect all users, kill LRT, etc. and start the maintenance.
  3. Disable monitoring system notifications.
  4. Switch back to old Tomcat.
    systemctl stop tomcat
    cd /opt/tomcat
    unlink current
    ln -s apache-tomcat-8.5.11 current
    systemctl start tomcat
  5. Check logs to see if the application started properly.
  6. Perform testing with selected use-cases, test connected end systems, etc. to make sure everything works as expected.
  7. THE DOWNTIME ENDS HERE.
  8. Enable monitoring system notifications.

Troubleshooting

The error message "The server understood the request but refuses to authorize it." when coming to IdM through Apache web server means that you have to set AJP secret

ProxyPass / ajp://127.0.0.1:8009/ secret=**tomcat_ajp_secret**

in the /etc/httpd/conf.d/ssl.conf as written in the standard server preparation tutorial (httpd_installation_and_configuration).