aerogear / keycloak-metrics-spi

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

Keycloak 25 - java.lang.ClassNotFoundException org.jboss.resteasy.spi.ResteasyProviderFactory #199

Open nicolabeghin opened 2 months ago

nicolabeghin commented 2 months ago

Description

I'm testing Keycloak from latest sources (next planned version: 25.x)

Expected Behavior

Have Keycloak start up.

Actual Behavior

Keycloak does not boot up due to java.lang.ClassNotFoundException org.jboss.resteasy.spi.ResteasyProviderFactory

Appending additional Java properties to JAVA_OPTS
Listening for transport dt_socket at address: 8787
ERROR: Unexpected error when starting the server in (production) mode
Error details:
java.lang.RuntimeException: Failed to start quarkus
    at io.quarkus.runner.ApplicationImpl.<clinit>(Unknown Source)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:70)
    at org.keycloak.quarkus.runtime.KeycloakMain.start(KeycloakMain.java:126)
    at org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand.run(AbstractStartCommand.java:35)
    at picocli.CommandLine.executeUserObject(CommandLine.java:2026)
    at picocli.CommandLine.access$1500(CommandLine.java:148)
    at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
    at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
    at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
    at picocli.CommandLine.execute(CommandLine.java:2170)
    at org.keycloak.quarkus.runtime.cli.Picocli.parseAndRun(Picocli.java:120)
    at org.keycloak.quarkus.runtime.KeycloakMain.main(KeycloakMain.java:105)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at io.quarkus.bootstrap.runner.QuarkusEntryPoint.doRun(QuarkusEntryPoint.java:62)
    at io.quarkus.bootstrap.runner.QuarkusEntryPoint.main(QuarkusEntryPoint.java:33)
Caused by: java.lang.NoClassDefFoundError: org/jboss/resteasy/spi/ResteasyProviderFactory
    at org.jboss.aerogear.keycloak.metrics.MetricsEndpointFactory.init(MetricsEndpointFactory.java:20)
    at org.keycloak.quarkus.runtime.integration.QuarkusKeycloakSessionFactory.<init>(QuarkusKeycloakSessionFactory.java:83)
    at org.keycloak.quarkus.runtime.KeycloakRecorder.configSessionFactory(KeycloakRecorder.java:111)
    at io.quarkus.deployment.steps.KeycloakProcessor$configureKeycloakSessionFactory343981823.deploy_5(Unknown Source)
    at io.quarkus.deployment.steps.KeycloakProcessor$configureKeycloakSessionFactory343981823.deploy(Unknown Source)
    ... 25 more
Caused by: java.lang.ClassNotFoundException: org.jboss.resteasy.spi.ResteasyProviderFactory
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
    at io.quarkus.bootstrap.runner.RunnerClassLoader.loadClass(RunnerClassLoader.java:115)
    at io.quarkus.bootstrap.runner.RunnerClassLoader.loadClass(RunnerClassLoader.java:65)
    ... 30 more

Environment

Docker

Steps to reproduce

Download latest sources from Keycloak and compile them. Add keycloak-metrics-spi 5.x to providers and try to startup server

ihard commented 3 weeks ago

keycloak 25 released, problem persists When deleting a module, the events page in the admin panel is broken, apparently keycloak cannot correctly handle the lack of subscription to events from the module with metrics.

nicolabeghin commented 3 weeks ago

I confirm as @ihard - not possible to use on latest Keycloak 25.x.x - could probably be fixed by open PR https://github.com/aerogear/keycloak-metrics-spi/pull/202 ?

ahbonsu commented 2 weeks ago

I confirm as @ihard - not possible to use on latest Keycloak 25.x.x - could probably be fixed by open PR #202 ?

Dont think so.

The missing class was provided by org.jboss.resteasy:resteasy-core-spi and is no longer in keycloak 25. Before 25 the tree looked like this (example ref. 23.03 for keycloak-etrics-spi 5.0.0):

+- org.keycloak:keycloak-services:jar:23.0.3:provided +- org.jboss.resteasy:resteasy-multipart-provider:jar:6.2.4.Final:provided +- org.jboss.resteasy:resteasy-core-spi:jar:6.2.4.Final:provided

so quickly overviewing it, I think that for compatibility with Keycloak 25.0.0+ org.jboss.aerogear.keycloak.metrics.MetricsEndpointFactory must be adjusted. (and i see already a comment in the code pointing to it)

jannickherrmann commented 2 weeks ago

Hi, i had the same issue. I've fixed it in the pull request #204 and have tested it locally with Keycloak version 25.0.0. Everything appears to be working correctly on my end.

alexted commented 1 week ago

@pb82 could you pay attention to this problem?