Search code examples
jerseyresteasydropwizardkeycloak

Using Keycloak 4.3.0.Final with dropwizard 1.3.1


I am having a problem with integrating keycloak into dropwizard. Keycloak requires the RestEasy client so i had to use the dependency :

<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-client</artifactId>
    <version>3.0.26.Final</version>
</dependency>

then I create my httpClient :

RxClient<RxCompletionStageInvoker> httpClient = new JerseyClientBuilder(environment)
                .using(configuration.getJerseyClientConfiguration())
                .buildRx(getName(), RxCompletionStageInvoker.class);

then i try to use the client, for example :

httpClient
.target(path)
.request()
.get();

and i get the error:

java.lang.ClassCastException: org.jboss.resteasy.client.jaxrs.internal.ClientRequestContextImpl cannot be cast to org.glassfish.jersey.client.ClientRequest

when i remove the dependency I get the JercyClient and all httpRequests works find but Keycloak builder fails, when I use RestEasy dependency keyCloak succeeds but all other http requests fails Have anyone faced this problem before? is there a way to control when to get the resteasy client and when to get the jersey client?


Solution

  • The solution was to use RestEasy dependency but not using the JersyClientBuilder:

    Client httpClient =  new ResteasyClientBuilder().build();