Why does Keycloak keep redeploying the same .jar file?

1.3k Views Asked by At

I have a custom SPI javascript provider, packaged in the .jar file, as described in the official Keycloak docs. For the local development, I'm using jboss/keycloak docker image via docker-compose file with the volume mapping to the standalone/deployments folder set. The package is deployed and works OK, but Keycloak keeps to redeploy the same file every 5 seconds:

11:43:58,304 INFO  [org.keycloak.subsystem.server.extension.KeycloakProviderDeploymentProcessor] (MSC service thread 1-8) Deploying Keycloak provider: custom-auth-provider.jar
11:43:58,320 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0013: Redeployed "custom-auth-provider.jar"
11:44:03,388 INFO  [org.keycloak.subsystem.server.extension.KeycloakProviderDeploymentProcessor] (MSC service thread 1-4) Undeploying Keycloak provider: custom-auth-provider.jar
11:44:03,395 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0028: Stopped deployment custom-auth-provider.jar (runtime-name: custom-auth-provider.jar) in 9ms
11:44:03,397 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0027: Starting deployment of "custom-auth-provider.jar" (runtime-name: "custom-auth-provider.jar")
11:44:03,409 INFO  [org.keycloak.subsystem.server.extension.KeycloakProviderDeploymentProcessor] (MSC service thread 1-6) Deploying Keycloak provider: custom-auth-provider.jar
11:44:03,425 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0016: Replaced deployment "custom-auth-provider.jar" with deployment "custom-auth-provider.jar"
11:44:08,471 INFO  [org.keycloak.subsystem.server.extension.KeycloakProviderDeploymentProcessor] (MSC service thread 1-1) Undeploying Keycloak provider: custom-auth-provider.jar
11:44:08,477 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-8) WFLYSRV0028: Stopped deployment custom-auth-provider.jar (runtime-name: custom-auth-provider.jar) in 11ms
11:44:08,479 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) WFLYSRV0027: Starting deployment of "custom-auth-provider.jar" (runtime-name: "custom-auth-provider.jar")
11:44:08,493 INFO  [org.keycloak.subsystem.server.extension.KeycloakProviderDeploymentProcessor] (MSC service thread 1-5) Deploying Keycloak provider: custom-auth-provider.jar
11:44:08,517 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0013: Redeployed "custom-auth-provider.jar"
11:44:13,573 INFO  [org.keycloak.subsystem.server.extension.KeycloakProviderDeploymentProcessor] (MSC service thread 1-3) Undeploying Keycloak provider: custom-auth-provider.jar
11:44:13,581 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0028: Stopped deployment custom-auth-provider.jar (runtime-name: custom-auth-provider.jar) in 11ms

Is this a desired behavior, or can I stop it somehow?

3

There are 3 best solutions below

0
On

In my case, the issue was caused by using a folder outside of WSL.

The volume seams to act weirdly when it points on a windows folder.

1
On

Apparently, the docker-compose volumes was the issue. With the automatic deployment of the .jar package by the Wildfly AS, properties of the file got changed, which caused Wildfly to consume it as an updated file. Changing the particular volume mapping to a 'bind' type

volumes:
      - type: bind  # bind mount type prevents file changes
        source: ./standalone/deployments/
        target: /opt/jboss/keycloak/standalone/deployments

did the trick

0
On

I know this will be a late answer, but:

You should specify the .jar path in docker-compose like this:

volumes:
  - type: bind
    source: ./keycloak/spi/keycloak-event-listener-spi-0.1.jar
    target: /opt/jboss/keycloak/standalone/deployments/keycloak-event-listener-spi-0.1.jar

This solves the problem for me