简体   繁体   English

使用来自 RestEasy Reactive 库的 RestResponse 时出错

[英]Error using RestResponse from RestEasy Reactive library

I am trying to use the RestResponse<T> object from org.jboss.resteasy.reactive on the return of my application resources since the javax.ws.rs.core.Response doesn't provide the generic type.我正在尝试使用来自org.jboss.resteasy.reactiveRestResponse<T> object 来返回我的应用程序资源,因为javax.ws.rs.core.Response不提供泛型类型。

I am getting the error when I call this endpoint:调用此端点时出现错误:

public RestResponse<List<SampleResponse>> findAll() {
    return ResponseBuilder.ok(sampleService.findAll()).build();
}

The error:错误:

Request failed: java.lang.ClassCastException: class org.jboss.resteasy.core.providerfactory.ResteasyProviderFactoryImpl cann
ot be cast to class org.jboss.resteasy.reactive.common.jaxrs.RuntimeDelegateImpl (org.jboss.resteasy.core.providerfactory.ResteasyProviderFactoryImpl and org.jboss.resteasy.reactive.common.jaxrs.RuntimeDelegateImpl are in unnamed mo
dule of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @3c153a1)

My dependencies in pom.xml:我在 pom.xml 中的依赖项:

<dependencies>
  <dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-hibernate-orm</artifactId>
  </dependency>
  <dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-hibernate-validator</artifactId>
  </dependency>
  <dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-rest-client</artifactId>
  </dependency>
  <dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-smallrye-openapi</artifactId>
  </dependency>
  <dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-resteasy-reactive-jackson</artifactId>
  </dependency>
  <dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-liquibase</artifactId>
  </dependency>
  <dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-smallrye-health</artifactId>
  </dependency>
  <dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-redis-client</artifactId>
  </dependency>
  <dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-arc</artifactId>
  </dependency>
  <dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-rest-client-jackson</artifactId>
  </dependency>
  <dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-config-yaml</artifactId>
  </dependency>
  <dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-junit5</artifactId>
    <scope>test</scope>
  </dependency>
  <dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-spring-data-jpa</artifactId>
  </dependency>
  <dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>${lombok.version}</version>
    <scope>compile</scope>
  </dependency>
  <dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-jdbc-postgresql</artifactId>
  </dependency>
  <dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-spring-web</artifactId>
  </dependency>
  <dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-resteasy-reactive</artifactId>
  </dependency>
</dependencies>

I just solved the problem... It was the order of dependecies.我刚刚解决了这个问题......这是依赖的顺序。 I switched quarkus-resteasy-reactive to the top and it is working now.我将quarkus-resteasy-reactive切换到顶部,它现在正在工作。

With RESTEasy Reactive, you should use quarkus-rest-client-reactive .使用 RESTEasy Reactive,您应该使用quarkus-rest-client-reactive quarkus-rest-client may bring some RESTEasy classic classes that conflict with the reactive version quarkus-rest-client可能会带来一些与响应式版本冲突的 RESTEasy 经典类

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM