Reputation: 57
I'm trying to change roles of a user in keycloak with the keycloak-admin-client in a spring boot application, but I can't even instanciate keycloak.
I'm trying to get the keycloak server here, but Im getting a InstantiationError
String serverUrl = "http://localhost:8080/auth";
String realm = "User-Service-Realm";
String clientId = "admin-cli";
Keycloak keycloak = Keycloak.getInstance(
serverUrl,
realm,
"admin",
"admin",
clientId);
Exception in thread "main" java.lang.InstantiationError: org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder
at org.keycloak.admin.client.Keycloak.<init>(Keycloak.java:58)
at org.keycloak.admin.client.Keycloak.getInstance(Keycloak.java:106)
at de.uni.stuttgart.isw.ccm.userservice.api.KeycloakAdminClientExample.main(KeycloakAdminClientExample.java:31)
Apparently its a problem with the admin-client itself, since the keycloak builder is based on the resteasyclientbuilder.
Upvotes: 2
Views: 7004
Reputation: 78795
You seem to have incompatible libraries or library versions. The error message complains that ResteasyClientBuilder
is abstract. That not the case in our working project.
So as a reference, here is an extract from our gradle file so you can see a working combination of library versions:
implementation 'org.keycloak:keycloak-admin-client:6.0.1'
implementation 'javax.ws.rs:javax.ws.rs-api:2.0'
implementation 'org.jboss.resteasy:resteasy-jaxrs:3.6.3.Final'
implementation 'org.jboss.resteasy:resteasy-client:3.6.3.Final'
implementation 'org.jboss.resteasy:resteasy-jackson2-provider:3.6.3.Final'
Update:
ResteasyClientBuilder
has become an abstract class with version 4.0 of RESTEasy. So it looks as if you are using version 4.x, while Keycloak expects 3.x.
Upvotes: 3