aerogear / keycloak-metrics-spi

Adds a Metrics Endpoint to Keycloak
Apache License 2.0
523 stars 151 forks source link

Updated KC dependency to 22.0.0 #169

Closed diversit closed 11 months ago

diversit commented 11 months ago

For compatibility with KC22: replaced Java EE with Jakarta EE. Test: replaced obsolete 'com.github.stefanbirker:system-rules' dependency with a similar library 'uk.org.webcompere:system-stubs-junit4'.

Note: this change might NOT be compatible with KC < 22.x !

Motivation

Metrics not compatible with Keycloak 22 due to change from Java EE to Jakarta EE. https://github.com/aerogear/keycloak-metrics-spi/issues/168

What

Replaces Java EE imports with Jakarta EE imports. No further code changes.

Why

Keycloak 22 replaced Java EE with Jakarta EE making this library not compatible anymore, throwing a ClassNotFoundException at startup.

How

Replaces Java EE imports with Jakarta EE imports. No further code changes.

For test had to replace the old (and obsolete?) system-rules dependency with a more current version by uk.org.compere due to module issues since Keycloak 22 now also is just for Java 17 (Java 11 compatibility was dropped).

 PrometheusExporterTest.shouldBuildPushgateway » InaccessibleObject Unable to make field private final java.util.Map java.util.Collections$UnmodifiableMap.m accessible: module java.base does not "opens java.util" to unnamed module @70beb599

Updating the dependency fixed this issue.

Verification Steps

  1. Add this version to KC 22 install
  2. Start KC 22
  3. Login to KC 22
  4. Enable 'metrics-listener' to realm events settings
  5. Logout en login to KC to trigger event to send to metrics listener
  6. Verify metics on /auth/realms/master/metrics endpoint

Checklist:

Progress

Additional Notes

Due to the changes in KC 22 (dropped Java 11 compatibility, change from Java EE to Jakarta EE), these changes are likely not compatible with KC versions < 22.x.

pb82 commented 11 months ago

thanks @diversit ! will give it a quick try and then merge this.

pb82 commented 11 months ago

This works as expected with Keycloak 22 :+1: However, I can also confirm that it does not work in older versions: java.lang.NoClassDefFoundError: jakarta/ws/rs/WebApplicationException.

So v4.0.0 with an explicit note makes sense.