Finicky detection of providers in the providers folder

Running keycloak in a docker container in start-dev mode. Mapping a directory on my system where the .jar files for my provider is created to the container at /opt/keycloak/providers. For some reason keycloak picks and chooses when it wants to detect a .jar file and build it. I cannot find any consistency in why it does detect and build sometimes and other times it doesn’t. It is driving me mad, because trying to develop a SPI this way is like banging one’s head against a brick wall. The provider compiles without error. The jar file is updated. Yet, most times keycloak won’t detect it when it starts, and even running kc.sh build is hit or miss. No joke, some times going into the code and adding a comment like // WHAT THE EFF IS WRONG WITH THIS THING, and recompiling it into a .jar file then running the kc.sh build command results in it being detected and appearing on the server info screen. But then I add a few lines of code, recompile and create a new .jar file. Go to keycloak and run kc.sh rebuild and it detects nothing. I have shutdown and removed the docker containers and recreated them. Still finicky about when it works or not.

What am I doing wrong? Besides trying to develop in a language like java

So, this is an example. First time it detected the provider. Added the following lines of code and ran the kc.sh build command and it detects nothing:

if (Boolean.FALSE.equals(user.isEnabled())) {
log.infof(“%s is disabled”, user.getUsername());
}

Another example.

The only thing I changed was the return value for the getId method of the factory. Changed it from “JESUS” to “disabled-account”, rebuild it, ran kc.sh build again. And notta :frowning:

Changed the return string to DISABLED-ACCOUNT, recompiled, ran kc.sh build and it now appears.

Hello. Which provider are you using. If it is an EvenListener provider, it will be displayed during build launches or configuration. But if you, for example, connect a user federation provider - do not wait for a message about this in the console that keycloak found it, look in the administrator console. And check for getId() method in Factory of your provider, it should give name of provider to include it.

1 Like