【问题标题】:Using Keycloak 4.3.0.Final with dropwizard 1.3.1使用 Keycloak 4.3.0.Final 和 dropwizard 1.3.1
【发布时间】:2019-04-01 11:35:04
【问题描述】:

我在将 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 客户端?

【问题讨论】:

    标签: jersey resteasy dropwizard keycloak


    【解决方案1】:

    解决方案是使用 RestEasy 依赖,但不使用 JersyClientBuilder:

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

    【讨论】:

      猜你喜欢
      • 2023-03-09
      • 2014-01-19
      • 1970-01-01
      • 1970-01-01
      • 2019-01-28
      • 2016-12-22
      • 2016-06-04
      • 2016-11-05
      • 2016-11-10
      相关资源
      最近更新 更多