Digital ID
Latest

Keycloak Upgrade 22.0.5 -> 24.0.3

📆
🏷
, ,

After running into more or less the same problem every damn keycloak upgrade it’s time to put some notes into place so I won’t struggle in the future anymore. At least not with the same problem.

  • Change into the root directory for keycloak

    cd /var/www
    
  • Download the latest release tarball

    curl -LO https://github.com/keycloak/keycloak/releases/download/24.0.3/keycloak-24.0.3.tar.gz
    
  • Change ownership

    chown _keycloak keycloak-24.0.3
    
  • Read the upgrade instructions! Most of the time it boils down to

    cp -Rpv keycloak-22.0.5/{conf,providers,themes} keycloak-24.0.3/
    

    for me

  • Change into the new release directory

    cd keycloak-24.0.3/
    
  • Stop old keycloak

    rcctl stop keycloak
    
  • This step is crucial and well hidden within the documentation of keycloak.

    JAVA_HOME=/usr/local/jdk-21 bin/kc.sh build
    

    Failing to do the build first before starting keycloak with the --optimized flag via my rc file results in an exception due to problems with the jdbc URL:

    2024-04-19 13:38:08,815 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" but is "jdbc:postgresql://localhost:5432/keycloak" [90046-224]
    
  • adjust daemon_execdir to reflect the new version in /etc/rc.d/keycloak

  • Start the new keycloak

    rcctl start keycloak
    
  • Clean up behind you

    rm -rd /var/www/keycloak-22.0.5