Skip to content

2.9. Switching From an Earlier Installation

This chapter explains how to switch an environment that already uses OPENMARU Cluster to the single installation file (openmaru-cluster-valve-all-5.1.0.jar). Read the section that matches what you use now.

What you use nowSection to read
The openmaru-cluster-valve-core and openmaru-cluster-valve-hotrod jars plus several library jars in Tomcat's lib"From Several Jars to One"
The khan-session-core and khan-session-hotrod jars in the application's WEB-INF/lib, used as a filter"Switching From the Earlier Version (khan-session)"

In either case, after the upgrade the session cookie (__KSMSID__) value changes at login, because session fixation protection is now on by default. If an external integration receives and uses this cookie value directly, test the login flow before upgrading. To keep the previous behavior, set sessionFixationProtection to false (see 2.2).

From Several Jars to One​

Remove all jars of the previous method from Tomcat's lib and add the new installation file. If the old openmaru-cluster-valve-hotrod jar remains, startup stops with KSM-SJ-002. Remove all other old jars as well.

The replacement script migrate-single-jar.sh does this for you. It is provided together with the installation file.

  • It moves only files whose names exactly match the file name lists in the script. Even if Tomcat's lib is shared with other products, other files are not touched.
  • It does not delete files; it moves them to a backup directory, so you can always roll back.
  • It leaves jamm-0.2.5.jar in place. This file is used for measuring session memory usage (-javaagent). If you do not use that feature, you can delete it yourself.

Procedure​

  1. Stop Tomcat.

  2. Check which files will be moved. Nothing is changed; only the list is shown.

    bin/migrate-single-jar.sh "$CATALINA_BASE/lib"
    • Review the list of jars to be moved.
    • If another product that shares the same lib uses a jar with the same name, keep it with --keep. It can be given more than once. Example: --keep slf4j-api-1.7.36.jar
    • Files shown under remaining old jars are earlier OPENMARU Cluster jars that are not in the lists. The script does not move them, so remove them yourself.
  3. Back up and switch.

    bin/migrate-single-jar.sh --apply --new-jar openmaru-cluster-valve-all-5.1.0.jar "$CATALINA_BASE/lib"
    • The backup is created in the parent directory of lib as openmaru-migrate-backup-<time>. To put it elsewhere, use --backup-dir <path> (not inside lib).
    • The backup directory also holds the lib listing before the switch (lib-before.txt) and the list of moved files (moved.txt). Write down the backup location printed in the output. You need it to roll back.
  4. In conf/logging.properties, prefix log names starting with org.infinispan or io.netty with io.openmaru.shaded.. If the WAS startup options contain -Dio.netty.* or -Dorg.jboss.logging.*, change them the same way (see "Adjusting Log Levels" and "Netty System Properties" in 2.7).

  5. Start Tomcat and check that the startup log contains the following line.

    bundled infinispan=13.0.11.Final-redhat-00001 netty=4.1.128.Final-redhat-00001 prefix=io.openmaru.shaded. jar=file:/…/openmaru-cluster-valve-all-5.1.0.jar mode=single

    If this line is missing or shows prefix=none mode=multi, an old jar was loaded first. If KSM-SJ-002 appears, remove the jars listed in old=[…] in the log.

Caution The script also moves the slf4j-api and slf4j-jdk14 jars. The new installation file does not need these libraries separately. If an application was borrowing slf4j from Tomcat's lib, NoClassDefFoundError: org/slf4j/… occurs after the switch. In that case, add slf4j to the application's WEB-INF/lib, or keep it in step 2 with --keep slf4j-api-1.7.36.jar.

Rolling Back​

  1. Stop Tomcat.

  2. Roll back using the backup location you wrote down in step 3.

    bin/migrate-single-jar.sh --restore --backup-dir <backup location> "$CATALINA_BASE/lib"

    The new installation file is moved to new-jar/ in the backup, and the moved jars return to lib. If a file with the same name already exists in lib, nothing is moved and the script stops. If you used --force-dir when moving, add it when rolling back as well.

  3. Restore logging.properties and the startup options by hand.

  4. Start Tomcat.

Script Options​

OptionWhat it does
(none)Shows only what would be moved (default)
--applyMoves the target jars to the backup directory
--new-jar <file>Copies the new installation file into lib during --apply. Without it, only the old jars are moved and you copy the new file yourself
--restore --backup-dir <path>Returns the moved jars and moves the new installation file into the backup
--backup-dir <path>Backup location (must be outside lib)
--keep <file name>Does not move this file. Can be given more than once
--force-dirAlso targets a directory that does not look like Tomcat's lib (for example, an application's WEB-INF/lib)

Switching From the Earlier Version (khan-session)​

The earlier version put khan-session-core-<version>.jar, khan-session-hotrod-<version>.jar, and library jars in the application's WEB-INF/lib and was used as a filter. In the new version the class names (packages) have changed and there is a single installation file. Setting names are unchanged.

What Changes​

WhatEarlier versionNew version
Installation fileskhan-session-core, khan-session-hotrod, and several library jarsA single openmaru-cluster-valve-all-5.1.0.jar
Filter classcom.opennaru.khan.session.filter.InfinispanHotRodSessionFilterio.openmaru.cluster.filter.InfinispanHotRodSessionFilter (Tomcat 10 or later: io.openmaru.cluster.jakarta.filter.…)
Listenercom.opennaru.khan.session.listener.SessionListener registered in web.xmlRegistered automatically (remove it from web.xml). Spring Boot registers it explicitly
Imports in application codecom.opennaru.khan.session.listener.SessionLoginManagerio.openmaru.cluster.listener.SessionLoginManager (Tomcat 10 or later: io.openmaru.cluster.jakarta.listener.…)
Allow listcom.opennaru.khan.session classesio.openmaru.cluster.KhanSessionMetadata
Spring Boot configurationConstants such as Constants.SESSION_TIMEOUTStrings such as "sessionTimeout" (same as the web.xml names)
Installation methodsFilter onlyOn Tomcat, the Valve method is also available

Procedure​

  1. Remove the khan-session-* jars and the library jars that came with them from the application's WEB-INF/lib. Keep libraries the application uses directly. Also remove the build dependency (com.opennaru.khan:khan-session-hotrod).
  2. Choose an installation method and add the new installation file (step 1 of 2.1 "Installation").
    • To keep using the filter method, put it in WEB-INF/lib.
    • To switch to the Tomcat Valve method, put it in Tomcat's lib and remove the filter registration from web.xml.
  3. Change <filter-class> in web.xml to the new class name and remove the <listener> line for SessionListener. Leave the <init-param> entries as they are.
  4. Change the com.opennaru.khan.session. imports in application code to io.openmaru.cluster. (Tomcat 10 or later: io.openmaru.cluster.jakarta.) and rebuild.
  5. In the allow list (java_serial_allowlist) in hotrod.properties, replace the com.opennaru.khan.session entry with io.openmaru.cluster.KhanSessionMetadata (see 2.7). The server list separator is ;.
  6. Deploy the application and confirm it with step 4 of 2.1.

Caution Plan on the assumption that sessions stored by the earlier version are not carried over after the switch. Users may need to log in again, so switch when traffic is low.