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.
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:
<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>
2
Answers
I just solved the problem... It was the order of dependecies. I switched
quarkus-resteasy-reactive
to the top and it is working now.With RESTEasy Reactive, you should use
quarkus-rest-client-reactive
.quarkus-rest-client
may bring some RESTEasy classic classes that conflict with the reactive version