Issue with Custom SPI in Keycloak Version 23.0.6 After Upgrade

Hello everyone,

I recently upgraded my Keycloak instance from version 20.0.5 to the latest version, 23.0.6, and encountered an issue with a custom Service Provider Interface (SPI) that I have been using. My custom SPI retrieves data from headers using context.getHttpRequest().getHttpHeaders().

Unfortunately, after the upgrade, it appears that the method getHttpRequest() is no longer being instantiated. I’ve been unable to determine the cause of this issue.

Has anyone experienced a similar problem, or does anyone have any insights on how to resolve this? Any guidance or suggestions would be greatly appreciated.

Thank you in advance for your help!

Have you recompiled your extension with the proper library version?
The underlying implementation has changed, thus, you’ll have to recompile/rebuild your implementation.

Hi @dasniko

Thanks for the answer. Yes I did! Do you mean mvn clean install, right?

Did not work

Have you adjusted the dependency versions in your pom.xml before doing a mvn clean package accordingly to your server version?
(install ist not necessary, as you don’t need an install in your local maven environment, you only need to package the .jar and copy the file to the Keycloak server)

Make sure the dependency in the extension matches the exact dependency of the server you run. Let’s say you use maven, then everything you use in your extension must be marked as provided and you can check that the versions match. You can start the empty keycloak as a docker container, look inside what are the versions, and then copy the exact library version in your pom.xml.

If my memory is correct this change related to the http request landed somewhere between Keycloak 20 and 21, so when I upgraded, after I changed the dependencies to the correct versions, I had the relevant compilation errors that guided me in fixing the code. I guess if you did not do that you have runtime errors? Or what do you mean by “not instantiated” ?

I’m currently facing an issue with my Keycloak setup running inside a Docker container. I’ve recently upgraded Keycloak to version 23.0.0 by updating the version in the .pom file. After the upgrade, I proceeded to compile my (SPI) by running the Maven command:

mvn clean package -DskipTests

Once the .jar file for the SPI was generated, I transferred it to my Docker container using the following Docker command:

docker cp providers/$(project)/target/*.jar $(container):/opt/keycloak/providers/

However, after starting the application and attempting to access context.getHttpRequest() within my custom SPI, I encountered the following error:

“No such instance method: getHttpRequest”

I’m wondering if I might have missed a step in the upgrade process or if there’s a specific configuration I need to adjust to resolve this issue.

Any help or suggestions would be greatly appreciated!

Can you share some code here? How does your class look like?

Thanks Guys, I found the issue.

The docker was running a different server version. My pipeline was not updating it.

1 Like