Keycloak upgrading from 3.4.3 to keycloak 10

Hi,
we have a client using key cloak 3.4.3 and now wants to update to latest and greatest key cloak. We initially started migrating h2 database as we have it on one of client’s machine and then eventually will do with oracle in test and prod env. we tried with installing new keycloak 8 version on clients local machine and copied data folder from older keycloak 3.4.3 instance and it does not worked. further we tried with upgrading from keycloak 3.4.3 to keycloak 6 and it worked but any further upgradation fails with error as
“Caused by: java.lang.NullPointerException
at org.keycloak.migration.migrators.MigrateTo8_0_0.migrateRealmCommon(MigrateTo8_0_0.java:72)
at org.keycloak.migration.migrators.MigrateTo8_0_0.lambda$migrate$0(MigrateTo8_0_0.java:49)
at java.util.LinkedList$LLSpliterator.forEachRemaining(LinkedList.java:1235)
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:647)
at org.keycloak.migration.migrators.MigrateTo8_0_0.migrate(MigrateTo8_0_0.java:49)
at org.keycloak.migration.MigrationModelManager.migrate(MigrationModelManager.java:105)
at org.keycloak.services.resources.KeycloakApplication.migrateModel(KeycloakApplication.java:272)
at org.keycloak.services.resources.KeycloakApplication.migrateAndBootstrap(KeycloakApplication.java:213)
at org.keycloak.services.resources.KeycloakApplication$1.run(KeycloakApplication.java:180)
at org.keycloak.models.utils.KeycloakModelUtils.runJobInTransaction(KeycloakModelUtils.java:227)
at org.keycloak.services.resources.KeycloakApplication.startup(KeycloakApplication.java:171)”

Can anyone have help here on this issue

@mkanis, @bathe, @MoroccanGeek, @mshushkov, @pkadian, @ others, please guide with any inputs to proceed further

Did you delete any auto-created clients in any realm?
The exception yields to migrating the Account client, but if you deleted it, the script will fail.

This is fixed in KC 9.x and up (I encountered the same error and did the PR fix).
So, try to use KC 9.x or 10.x, this exception should no occur.
Alternatively, re-create the Account client.

Deleting auto-created clients in a realm is not the way to go. Just disable the ones you don’t want/need, this prevents further issues.

@dasniko, @mkanis, @bathe, @MoroccanGeek, @mshushkov, @pkadian, @dasniko anis, @bathe, @MoroccanGeek, @mshushkov, @pkadian, @others
i tried with key cloak 10.0.2 but this time it failed with new error which doesnt seems to make any sense at all.
"

2020-07-16 14:29:00.125Z ERROR [Controller Boot] o.j.a.c.management-operation
{{}} WFLYCTL0013: Operation (“add”) failed - address: ([(“subsystem” => “microprofile-metrics-smallrye”)]): java.lang.NullPointerException
at org.wildfly.extension.microprofile.metrics.MicroProfileMetricsSubsystemAdd$2.execute(MicroProfileMetricsSubsystemAdd.java:86)
at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:999)
at org.jboss.as.controller.AbstractOperationContext.processStages(AbstractOperationContext.java:743)
at org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:467)
at org.jboss.as.controller.OperationContextImpl.executeOperation(OperationContextImpl.java:1413)
at org.jboss.as.controller.ModelControllerImpl.boot(ModelControllerImpl.java:527)
at org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:515)
at org.jboss.as.controller.AbstractControllerService.boot(Abstrac "

and

" {{}} WFLYCTL0190: Step handler org.jboss.as.controller.AbstractAddStepHandler$1@599d88e3 for operation add at address [(“subsystem” => “transactions”)] failed – java.util.concurrent.RejectedExecutionException: java.util.concurrent.RejectedExecutionException
at org.jboss.threads.RejectingExecutor.execute(RejectingExecutor.java:37)
at org.jboss.threads.EnhancedQueueExecutor.rejectShutdown(EnhancedQueueExecutor.java:2026)
at org.jboss.threads.EnhancedQueueExecutor.execute(EnhancedQueueExecutor.java:757)
at org.jboss.as.controller.notification.NotificationSupports$NonBlockingNotificationSupport.emit(NotificationSupports.java:95)
at org.jboss.as.controller.OperationContextImpl.notifyModificationBegun(OperationContextImpl.java:877)
at org.jboss.as.controller.OperationContextImpl.ensureWriteLockForRuntime(OperationContextImpl.java:866)
at org.jboss.as.controller.OperationContextImpl.removeService(OperationContextImpl.java:639)"

Please Share complete logs of the keycloak. There should be another error or warning above the error which you shared with me.

Try to share debug logs. Enable logging on keycloak subsystem and change console log handler.

$ ./jboss-cli.sh --controller=192.0.0.0:9990 --connect

[standalone@192.0.0.0:9990 /] /subsystem=logging/logger=org.keycloak/:add(category=org.keycloak,level=TRACE)

$ [standalone@192.0.0.0:9990 /]/subsystem=logging/console-handler=CONSOLE:change-log-level(level=TRACE)

Thanks & Regards

@dasniko, @mkanis, @bathe, @MoroccanGeek, @mshushkov, @pkadian, @dasniko anis, @bathe, @MoroccanGeek, @mshushkov, @pkadian, @others tried with all the log levels i.e. trace and also with log level “ALL” but there is no any error apart from the below:

"

2020-07-16 14:29:00.125Z ERROR [Controller Boot] o.j.a.c.management-operation
{{}} WFLYCTL0013: Operation (“add”) failed - address: ([(“subsystem” => “microprofile-metrics-smallrye”)]): java.lang.NullPointerException
at org.wildfly.extension.microprofile.metrics.MicroProfileMetricsSubsystemAdd$2.execute(MicroProfileMetricsSubsystemAdd.java:86)
at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:999)
at org.jboss.as.controller.AbstractOperationContext.processStages(AbstractOperationContext.java:743)
at org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:467)
at org.jboss.as.controller.OperationContextImpl.executeOperation(OperationContextImpl.java:1413)
at org.jboss.as.controller.ModelControllerImpl.boot(ModelControllerImpl.java:527)
at org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:515)
at org.jboss.as.controller.AbstractControllerService.boot(Abstrac "

and

" {{}} WFLYCTL0190: Step handler org.jboss.as.controller.AbstractAddStepHandler$1@599d88e3 for operation add at address [(“subsystem” => “transactions”)] failed – java.util.concurrent.RejectedExecutionException: java.util.concurrent.RejectedExecutionException
at org.jboss.threads.RejectingExecutor.execute(RejectingExecutor.java:37)
at org.jboss.threads.EnhancedQueueExecutor.rejectShutdown(EnhancedQueueExecutor.java:2026)
at org.jboss.threads.EnhancedQueueExecutor.execute(EnhancedQueueExecutor.java:757)
at org.jboss.as.controller.notification.NotificationSupports$NonBlockingNotificationSupport.emit(NotificationSupports.java:95)
at org.jboss.as.controller.OperationContextImpl.notifyModificationBegun(OperationContextImpl.java:877)
at org.jboss.as.controller.OperationContextImpl.ensureWriteLockForRuntime(OperationContextImpl.java:866)
at org.jboss.as.controller.OperationContextImpl.removeService(OperationContextImpl.java:639)"

This is why i did mentioned the error doesnt make any sense at all.

@dasniko, @mkanis, @bathe, @MoroccanGeek, @mshushkov, @pkadian, @others, any idea on how to proceed further

@dasniko, @mkanis, @bathe, @MoroccanGeek, @mshushkov, @pkadian, @others, any idea on how to proceed further

i am also stuck on it. Anyone have idea for this.

Hi every1,

i was able to get this issue resolved. please follow below steps in order to resolve:

  1. import realms from import feature in keycloak. you can import all the relams in one go or one file for one realm.
  2. create a empty DB and let keycloak point to that db.
    once keycloak is started this new db is updated with keycloak schema.
  3. now in keycloak export json file created in step1 and if success upgrade is done. In case of failure, create realm manually with same name as in old keycloak and then import json or u can import json while creating realm as well.
1 Like