keycloak-dropwizard-integration
keycloak-dropwizard-integration copied to clipboard
java.lang.NoClassDefFoundError: org/keycloak/adapters/authorization/spi/HttpResponse
Hi,
I'm upgrading from v 1.2 to 2.0.0 with Dropwizard version 3.0.6. I'm sure I'm missing something, but for each request I'm getting an error about a missing class java.lang.NoClassDefFoundError: org/keycloak/adapters/authorization/spi/HttpResponse
.
I am importing the module in Gradle with
implementation 'de.ahus1.keycloak.dropwizard:keycloak-dropwizard:2.0.0'
Is there anything else needed? I can't find anything about other dependencies in the docuemntation.
Thanks for your great work on this package!
Full stack trace:
WARN [2024-02-09 11:59:57,328] org.eclipse.jetty.server.HttpChannel: /sellers
! java.lang.ClassNotFoundException: org.keycloak.adapters.authorization.spi.HttpResponse
! at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
! at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
! at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
! ... 36 common frames omitted
! Causing: java.lang.NoClassDefFoundError: org/keycloak/adapters/authorization/spi/HttpResponse
! at org.keycloak.adapters.jetty.core.AbstractKeycloakJettyAuthenticator.validateRequest(AbstractKeycloakJettyAuthenticator.java:310)
! at de.ahus1.keycloak.dropwizard.KeycloakDropwizardAuthenticator.validateRequest(KeycloakDropwizardAuthenticator.java:39)
! at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:528)
! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
! at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:223)
! at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1384)
! at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:176)
! at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:484)
! at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:174)
! at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1306)
! at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)
! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
! at io.dropwizard.metrics.jetty10.InstrumentedHandler.handle(InstrumentedHandler.java:314)
! at io.dropwizard.jetty.RoutingHandler.handle(RoutingHandler.java:52)
! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
! at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:822)
! at io.dropwizard.jetty.ZipExceptionHandlingGzipHandler.handle(ZipExceptionHandlingGzipHandler.java:26)
! at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:46)
! at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:173)
! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
! at org.eclipse.jetty.server.Server.handle(Server.java:563)
! at org.eclipse.jetty.server.HttpChannel$RequestDispatchable.dispatch(HttpChannel.java:1598)
! at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:753)
! at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:501)
! at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:287)
! at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:314)
! at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
! at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)
! at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:421)
! at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:390)
! at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:277)
! at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.produce(AdaptiveExecutionStrategy.java:193)
! at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:969)
! at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1194)
! at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1149)
! at java.base/java.lang.Thread.run(Thread.java:829)
Hi, it seems that a dependency is currently missing from the transitive dependencies.
Try adding org.keycloak:keycloak-policy-enforcer
as a dependency to resolve this as a workaround. A future version of this library will include it.
BTW, I recommend that you add a Keycloak client dependency to your project that you can update as often as Keycloak upgrades, as this library doesn't track all releases of Keycloak unless there are incompatible changes.
Thanks Alexander, I'll try that.
I do have the Keycloak Admin client in my project. But it points at an older version of Keycloak as my server is a few versions behind the latest.
It is hard to keep a live production server of Keycloak up to date as it does not support rolling upgrades and requires some down time. I know it is off topic, but do you have any suggestions in how to keep it up to date without down time?
It is hard to keep a live production server of Keycloak up to date as it does not support rolling upgrades and requires some down time.
I know, still keeping it up to date is without an alternative if you want to stay safe. You might want to reduce the downtime by automating the upgrade as much as possible.