'trying to up keycloak with docker but it's not starting . Operation ("add") failed - address:

05:49:02,840 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([("subsystem" => "microprofile-metrics-smallrye")]): java.lang.NullPointerException
        at [email protected]//org.wildfly.extension.microprofile.metrics.MicroProfileMetricsSubsystemAdd$2.execute(MicroProfileMetricsSubsystemAdd.java:86)
        at [email protected]//org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:999)
        at [email protected]//org.jboss.as.controller.AbstractOperationContext.processStages(AbstractOperationContext.java:743)
        at [email protected]//org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:467)
        at [email protected]//org.jboss.as.controller.OperationContextImpl.executeOperation(OperationContextImpl.java:1413)
        at [email protected]//org.jboss.as.controller.ModelControllerImpl.boot(ModelControllerImpl.java:527)
        at [email protected]//org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:515)
        at [email protected]//org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:477)
        at [email protected]//org.jboss.as.server.ServerService.boot(ServerService.java:451)
        at [email protected]//org.jboss.as.server.ServerService.boot(ServerService.java:404)
        at [email protected]//org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:416)
        at java.base/java.lang.Thread.run(Thread.java:834)


Solution 1:[1]

I had this error while trying to run Keycloak in a docker-compose setup. My problem was caused because Keycloak was unable to connect to the database container. In fact keycloak startup logs were complaining about database connection problems few lines prior the error "... Operation ("add") failed ..."

Solution 2:[2]

One of the reasons why the Keycloak start-up might fail is that you missed to enable the upload scripts flag.

The flag is deprecated and is normally only necessary if you want to do a realm import via the admin interface but in my case it was also necessary to enable the flag if I wanted to start-up Keycloak with an import file. Otherwise the same exception would be thrown that you provided in the original question.

The start-up param for enabling the flag is: -Dkeycloak.profile.feature.upload_scripts=enabled

A small disclaimer here. As the documentation states this flag should not be continuously enabled. So just enable it for the initial import and persist your realm configuration in an external database.

Solution 3:[3]

For me, running the container in a docker-compose situation, adding the DB_VENDOR env variable helped:

  keycloak:
    image: jboss/keycloak
    environment:
      KEYCLOAK_USER: admin
      KEYCLOAK_PASSWORD: admin
      DB_VENDOR: h2

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dovydas Giršvaldas
Solution 2 pyb
Solution 3 Kajzer