Hi
I’ve developed a SPI that implements UserStorageProvider.
This provider uses the RestClient to connect an external service. Deploying the SPI on the new version (17) I got an error with only the RestClient class name as message. It seems that Keycloak didn’t find the implementation of the RestClient.
Looking at the logs I saw that quarkus starts without the features quarkus-rest-client and quarkus-rest-client-jackson.
Which is the best way to add this dependencies?
Thanks
ps
I tried with either resteasy RestClient either microprofile RestClient
As Keycloak 17 doesn‘t use RestEasyClient, it‘s not bundled anymore. Before, with Wildfly, there was a whole bloated application server which had more modules than Keycloak needed. With Quarkus, only the libs which are needed by Keycloak are contained.
You can deploy your custom libraries together with your custom extension to the /providers
folder of Keycloak. But be careful, the resteasy version in the pom‘s are still on 3.x, while at runtime they are currently 4.7.5.Final!
Alternatively, you can rewrite your extension to use Keycloak‘s SimpleHttp
class, which provides some simple to use convenience methods for all HTTP verbs. Going this way, you don‘t need additional libs.
I’ve added this libraries, that are the dependecies of resteasy rest client 4.75, and that are missing in the keycloak lib
quarkus-rest-client-jackson
quarkus-rest-client
quarkus-apache-httpclient
quarkus-rest-client-config
microprofile-rest-client-api
resteasy-client-microprofile
resteasy-client-microprofile-base
resteasy-client,resteasy-client-api
resteasy-cdi
httpasyncclient
httpcore-nio
But I got this error
ERROR: RESTEASY010615: Unable to obtain ResteasyCdiExtension instance.
After many attempts I decided to proceed with the second option, reimplementing my SPI using SimpleHttp
class
I too gave up on the RestEasyHttpClient after way too many hours. Since we’re using OpenAPI, using SimpleHttp
was not an option. But seeing that SimpleHttp
depends on the standard apache httpclient, using the OpenAPI java
generator with library apache-httpclient
led to something usable. Request Filters need to be rewritten to Interceptors but apart from that it worked out pretty straightforward.
I spent also many many hours to get the RestEasyHttpClient way working on Keycloak 19 but ended up in the same “Unable to obtain ResteasyCdiExtension instance” Error. The only way was to use SimpleHttp, which was a terrible mess. No usable documentation for this!
I still not understand, why there was a ResteasyCdiExtension instance Error. Did anyone get this to work?