Using a rest client in a keycloak extension

1,080 views
Skip to first unread message

Paul Schwabauer

unread,
Dec 18, 2023, 8:44:45 AM12/18/23
to Keycloak User
Hi,
with the release of Keycloak 23, it is no longer possible to use the `ResteasyClientBuilder`.  Are there other rest clients that could be used inside a keycloak extension?
I tried `quarkus-resteasy-reactive` without success as `kc.sh build` fails with: io.smallrye.config.ConfigSourceFactory: io.smallrye.config.PropertiesLocationConfigSourceFactory not a subtype and using RestEasy results in dependency problems when building with quarkus.

Thanks in advance!

---
Paul

Fabio Pereira

unread,
Jan 10, 2024, 5:33:45 AM1/10/24
to Keycloak User
Hi, 

We are facing the same issue, have you found some solution for this? Thanks!

Garth

unread,
Jan 10, 2024, 6:17:09 AM1/10/24
to keyclo...@googlegroups.com
It's not an ideal fix, but you need to build a custom version of Keycloak. I posted the issue and the not ideal "solution" here: https://github.com/keycloak/keycloak/issues/25589#issuecomment-1872296228
> --
> You received this message because you are subscribed to the Google
> Groups "Keycloak User" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to keycloak-use...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/keycloak-user/fa86af2c-ec6c-4d39-b59a-034118688487n%40googlegroups.com
> <https://groups.google.com/d/msgid/keycloak-user/fa86af2c-ec6c-4d39-b59a-034118688487n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Ivan Atanasov

unread,
Jan 10, 2024, 9:48:58 AM1/10/24
to keyclo...@googlegroups.com

You can potentially use different client. We used Feign with success. The downside been the need to pull external dependency.

ivan

--
You received this message because you are subscribed to the Google Groups "Keycloak User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keycloak-use...@googlegroups.com.

Niko Köbler

unread,
Jan 11, 2024, 3:41:51 PM1/11/24
to Keycloak User
Keycloak already gives you resources you can use in your extensions:

Timothy Vogel

unread,
Jun 3, 2024, 12:42:20 PM6/3/24
to Keycloak User
Thanks to Niko for the link!  This will help me achieve my solution!

Andrey M.

unread,
Jul 12, 2024, 5:40:33 AM7/12/24
to Keycloak User
Hi all. We're facing the same issue when upgrading from Keycloak 22 to Keycloak 24.

Our extension is using a third-party library which requires Jakarta RS WS client. So far `ClientBuilder.buildClient()` worked well.
We don't have an option to alter this, so we can't just switch to java.net.HttpClient for example. A `jakarta.ws.rs.client.Client` implementation is the only option.

Also, building our own Keycloak is not an option because we're using RedHat build of Keycloak and paying for RH support.
I've already opened a support ticket to see what their recommendation would be on this. Meanwhile we're trying to find some ways to resolve it.

We tried to bundle "io.quarkus:quarkus-resteasy-client" and "io.quarkus:quarkus-resteasy-jackson" with our extension excluding already existing libraries to avoid conflicts, but we get the following error in "kc.sh build" output:

> 8.015 ERROR: Build failure: Build failed due to errors
> 8.015   [error]: Build step io.quarkus.arc.deployment.ArcProcessor#registerBeans threw an exception: java.lang.NullPointerException: Cannot invoke "org.jboss.jandex.ClassInfo.name()" because "currentClazz" is null
>8.015   at io.quarkus.resteasy.reactive.server.deployment.ResteasyReactiveProcessor.createTypedAnnotationInstance(ResteasyReactiveProcessor.java:876)

This is our current dependency declaration in Gradle build script just in case:

implementation ('io.quarkus:quarkus-resteasy-client:3.8.5') {
    exclude group: 'io.quarkus', module: 'quarkus-arc'
    exclude group: 'io.quarkus', module: 'quarkus-core'
    exclude group: 'io.quarkus', module: 'quarkus-resteasy-common'
    exclude group: 'jakarta.interceptor', module: 'jakarta.interceptor-api'
    exclude group: 'jakarta.ws.rs', module: 'jakarta.ws.rs-api'
    exclude group: 'org.apache.httpcomponents', module: 'httpasyncclient'
    exclude group: 'org.jboss.logging', module: 'commons-logging-jboss-logging'
    exclude group: 'org.eclipse.microprofile.config', module: 'microprofile-config-api'
}
implementation ('io.quarkus:quarkus-resteasy-jackson:3.8.5') {
    exclude group: 'io.quarkus', module: 'quarkus-arc'
    exclude group: 'io.quarkus', module: 'quarkus-core'
    exclude group: 'io.quarkus', module: 'quarkus-jackson'
    exclude group: 'io.quarkus', module: 'quarkus-vertx-http'
    exclude group: 'jakarta.xml.bind', module: 'jakarta.xml.bind-api'
    exclude group: 'io.smallrye.reactive', module: 'smallrye-mutiny-vertx-uri-template'
    exclude group: 'org.eclipse.microprofile.config', module: 'microprofile-config-api'
}

The problem seems to be caused by "io.quarkus:quarkus-resteasy-jackson" specifically. Without it the ClientBuilder works, but it throws runtime exceptions when trying to use JSON content type.

Any suggestions? Has anyone managed to solve this?
понедельник, 3 июня 2024 г. в 19:42:20 UTC+3, Timothy Vogel:

Andrey M.

unread,
Jul 15, 2024, 4:17:07 AM7/15/24
to Keycloak User
Hello again.

I managed to find a way to get it working by replacing "io.quarkus:quarkus-resteasy-jackson" with "org.jboss.resteasy:resteasy-jackson2-provider".
Not sure if it's a good long-term solution though, but it does allow us to upgrade to Keycloak 24.

implementation ('io.quarkus:quarkus-resteasy-client:3.8.5') {
exclude group: 'io.quarkus', module: 'quarkus-arc'
exclude group: 'io.quarkus', module: 'quarkus-core'
exclude group: 'io.quarkus', module: 'quarkus-resteasy-common'
exclude group: 'jakarta.interceptor', module: 'jakarta.interceptor-api'
exclude group: 'jakarta.ws.rs', module: 'jakarta.ws.rs-api'
exclude group: 'org.apache.httpcomponents', module: 'httpasyncclient'
exclude group: 'org.jboss.logging', module: 'commons-logging-jboss-logging'
exclude group: 'org.eclipse.microprofile.config', module: 'microprofile-config-api'
}
implementation ('org.jboss.resteasy:resteasy-jackson2-provider:6.2.7.Final') {
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations'
exclude group: 'jakarta.servlet', module: 'jakarta.servlet-api'
exclude group: 'org.jboss.logging', module: 'jboss-logging'
}

пятница, 12 июля 2024 г. в 12:40:33 UTC+3, Andrey M.:

Gilvan Filho

unread,
Aug 1, 2024, 3:21:19 AM8/1/24
to Keycloak User
Hi..
Andrey I have a question: Why did you used quarkus 3.8.5 instead of 3.8.4 which are version used by Red Hat Build of Keycloak 24?
Reply all
Reply to author
Forward
0 new messages