Import previously exported realm

I exported a realm from an instance of keycloak 6.0.1 into a json file This was successful.
When I tried to import the data into an instance of keycloak 7.0.0 on the same machine (having stopped 6.0.1) I ad an error with regard to microfile-metrics-smallrye.

So I put that to one side. I have now tried, on a different machine, running keycloak in a container. I copied over the json data and run

~$ docker run -e KEYCLOAK_USER=admincloak -p 8080:8080 -e KEYCLOAK_PASSWORD=123456 -e “KEYCLOAK_IMPORT=/tmp/keycloak_data.json -Dkeycloak.profile.feature.upload_scripts=enabled” -v /tmp/keycloak_data.json:/tmp/keycloak_data.json jboss/keycloak

The error output is

ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation (“add”) failed - address: ([(“subsystem” => “microprofile-metrics-smallrye”)]): java.lang.NullPointerException
at org.wildfly.extension.microprofile.metrics-smallrye@18.0.1.Final//org.wildfly.extension.microprofile.metrics.MicroProfileMetricsSubsystemAdd$2.execute(MicroProfileMetricsSubsystemAdd.java:86)
at org.jboss.as.controller@10.0.3.Final//org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:999)
at org.jboss.as.controller@10.0.3.Final//org.jboss.as.controller.AbstractOperationContext.processStages(AbstractOperationContext.java:743)
at org.jboss.as.controller@10.0.3.Final//org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:467)
at org.jboss.as.controller@10.0.3.Final//org.jboss.as.controller.OperationContextImpl.executeOperation(OperationContextImpl.java:1413)
at org.jboss.as.controller@10.0.3.Final//org.jboss.as.controller.ModelControllerImpl.boot(ModelControllerImpl.java:521)
at org.jboss.as.controller@10.0.3.Final//org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:472)
at org.jboss.as.controller@10.0.3.Final//org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:434)
at org.jboss.as.server@10.0.3.Final//org.jboss.as.server.ServerService.boot(ServerService.java:435)
at org.jboss.as.server@10.0.3.Final//org.jboss.as.server.ServerService.boot(ServerService.java:394)
at org.jboss.as.controller@10.0.3.Final//org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:374)
at java.base/java.lang.Thread.run(Thread.java:834)

I have looked at cant-import-realm-using-docker-image and importing-realm-8-0-2-docker and they were useful - I added the scripts=enabled param but I still get the microprofile.metrics.smallrye error.

Just to emphasise I am using an export from 6.0.1 to the latest container which is 9.0.2 from what I can see on the docker hub page. Is this allowed?

Just to add if I use the 6.0.1 tagged container then I get the same error.

I don’t know if it’s possible to do that.

Small changes wouldn’t have a great impact on the export but we are talking major versions here.
I’m afraid you’ll still need to upgrade to 9.0.2 and then do a new export from that one but I could be wrong, maybe it’s possible, I never tried it that way to be honest.

The 6.0.1 container should work if your current version is the same. Can you show us the full command you use?

So I used the command as detailed in the original question.
To extend that, do you have any idea why it complains about microprofile-metrics-smallrye or what that it does, it is loaded in the XML file.
With a NPE, it suggests it is missing when wildfly tries to load it.

Try running with the following extra params, it’s possible the error is because of the missing OVERWRITE_EXISTING one and/or others.

-Dkeycloak.migration.action=import -Dkeycloak.migration.provider=singleFile -Dkeycloak.profile.feature.upload_scripts=enabled -Dkeycloak.migration.file=/tmp/keycloak_data.json -Dkeycloak.migration.strategy=OVERWRITE_EXISTING

Hi @zonaut,
exactly the same error message.
So I used
~$ docker run -e KEYCLOAK_USER=admincloak -p 8080:8080 -e KEYCLOAK_PASSWORD=123456 -e “KEYCLOAK_IMPORT=/tmp/keycloak_data.json -Dkeycloak.profile.feature.upload_scripts=enabled -Dkeycloak.migration.strategy=OVERWRITE_EXISTING” -v /tmp/keycloak_data.json:/tmp/keycloak_data.json jboss/keycloak:6.0.1

As the docker hub page docs say for import.

The problem does centre around the microprofile-metrics-smallrye entry in the standalone.xml file. Now in the system that exported the json file, there is a default entry in that standalone.xml file for microprofile-metrics-smallrye and I assume there is one in the container image. There is no mention of microprofile-metrics-smallrye in the json file as there should not be.

What is so special about microprofile-metrics-smallrye?