Cannot invoke "org.keycloak.storage.federated.UserFederatedStorageProvider.getNotBeforeOfUser(org.keycloak.models.RealmModel, String)" because the return value of "org.keycloak.storage.UserStorageManager.getFederatedStorage()" is null

Hi,

Recently we tried to upgrade our custom provider to keycloak 25.0.5.

The custom provider is based on:

and is connecting to an oracle database.

(and was working in keycloak 19 :-))

After a lot of changes in the code, we get the code compiled and build.

When we test it, we are getting:

[org.keycloak.services] (executor-thread-1) KC-SERVICES0013: Failed authentication: java.lang.NullPointerException: Cannot invoke “org.keycloak.storage.federated.UserFederatedStorageProvider.getNotBeforeOfUser(org.keycloak.models.RealmModel, String)” because the return value of “org.keycloak.storage.UserStorageManager.getFederatedStorage()” is null
at org.keycloak.storage.UserStorageManager.getNotBeforeOfUser(UserStorageManager.java:777)
at org.keycloak.models.cache.infinispan.UserCacheSession.cacheUser(UserCacheSession.java:340)
at org.keycloak.models.cache.infinispan.UserCacheSession.getUserAdapter(UserCacheSession.java:308)
at org.keycloak.models.cache.infinispan.UserCacheSession.getUserByUsername(UserCacheSession.java:286)
at org.keycloak.models.utils.KeycloakModelUtils.findUserByNameOrEmail(KeycloakModelUtils.java:253)
at org.keycloak.authentication.authenticators.browser.AbstractUsernameFormAuthenticator.getUserFromForm(AbstractUsernameFormAuthenticator.java:165)
at org.keycloak.authentication.authenticators.browser.AbstractUsernameFormAuthenticator.getUser(AbstractUsernameFormAuthenticator.java:144)
at org.keycloak.authentication.authenticators.browser.AbstractUsernameFormAuthenticator.validateUserAndPassword(AbstractUsernameFormAuthenticator.java:125)
at org.keycloak.authentication.authenticators.browser.UsernamePasswordForm.validateForm(UsernamePasswordForm.java:55)
at org.keycloak.authentication.authenticators.browser.UsernamePasswordForm.action(UsernamePasswordForm.java:48)
at org.keycloak.authentication.DefaultAuthenticationFlow.processAction(DefaultAuthenticationFlow.java:151)
at org.keycloak.authentication.AuthenticationProcessor.authenticationAction(AuthenticationProcessor.java:1031)
at org.keycloak.services.resources.LoginActionsService.processFlow(LoginActionsService.java:376)
at org.keycloak.services.resources.LoginActionsService.processAuthentication(LoginActionsService.java:347)
at org.keycloak.services.resources.LoginActionsService.authenticate(LoginActionsService.java:339)
at org.keycloak.services.resources.LoginActionsService.authenticateForm(LoginActionsService.java:405)
at org.keycloak.services.resources.LoginActionsService$quarkusrestinvoker$authenticateForm_13d428b70e62601585246c086a52f40868a3208e.invoke(Unknown Source)
at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:141)
at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:582)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:1583)

Any suggestion in which direction we need to look? :-s

Thanks!

Kris

Same issue for keycloak v24. ++

Same in Keycloak v26.0.2

You have to implement
UserFederatedStorageProvider with it's UserFederatedStorageProviderFactory.

and put it into META-INF.services
org.keycloak.storage.federated.UserFederatedStorageProviderFactory

This is a link to a JDBC SPI that’s working with Java 21 / Keycloak 26. I haven’t run into this specific exception, but looking through this source code might help pinpoint your issue so that you can upgrade.

https://github.com/bekwam/bekwam-jdbc-user-storage-spi

Thanks, I’ve already solved by implementing UserFederatedStorageProvider
B.