我在将keycloak集成到dropwizard时遇到问题。 Keycloak需要RestEasy客户端,所以我不得不使用依赖项:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>3.0.26.Final</version>
</dependency>
然后创建我的httpClient:
RxClient<RxCompletionStageInvoker> httpClient = new JerseyClientBuilder(environment)
.using(configuration.getJerseyClientConfiguration())
.buildRx(getName(), RxCompletionStageInvoker.class);
然后我尝试使用客户端,例如:
httpClient
.target(path)
.request()
.get();
我得到了错误:
java.lang.ClassCastException: org.jboss.resteasy.client.jaxrs.internal.ClientRequestContextImpl cannot be cast to org.glassfish.jersey.client.ClientRequest
当我删除依赖项时,我得到了JercyClient并且所有httpRequests都可以找到,但是Keycloak构建器失败了,当我使用RestEasy依赖项时,keyCloak成功了,但是所有其他http请求都失败了 有人遇到过这个问题吗?有什么方法可以控制何时获得resteasy客户以及何时获得jersey客户?
答案 0 :(得分:0)
解决方案是使用RestEasy依赖项,而不使用JersyClientBuilder:
Client httpClient = new ResteasyClientBuilder().build();