0

As I am working on QUarkus application I am trying to return Uni but it giving me error:

@GET
@javax.ws.rs.Path("/notification/typeCount")
@Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN}) 
public Uni<Response> getNoti(){
      return Uni.createFrom().item(getAllCount()).onItem().transform(f -> f != null ? Response.ok(f) : Response.ok(null))
      .onItem().transform(ResponseBuilder::build);
}

public Uni<Object> getAllCount() {
      
    try{        
        sql="my query"; 

        return client.query(sql).execute().onItem().transform(pgRowSet -> {
            Map<String, Object> l = CUtils.mapLogic(pgRowSet);
                return l;
        });
    }
    catch(Exception e){
        return null;
    }
}

But while calling this request from front-end it is giving me below error:

RESTEASY002020: Unhandled asynchronous exception, sending back 500: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class io.smallrye.mutiny.context.ContextPropagationUniInterceptor$2 and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)

Please let me know how to resolve it.

I found one way but I don't think it's proper, if I change below lines:

From:

return Uni.createFrom().item(getAllCount()).onItem().transform(f -> f != null ? Response.ok(f) : Response.ok(null))
      .onItem().transform(ResponseBuilder::build);

To:

return Uni.createFrom().item(getAllCount()).onItem().transform(f -> f != null ? Response.ok(f.await().indefinitely()) : Response.ok(null))
      .onItem().transform(ResponseBuilder::build);

than it will work. so if I add "f.await().indefinitely()" it works, my question is will it be still reactive?

user3458271
  • 638
  • 12
  • 31

1 Answers1

0

If you are using traditional RESTEasy, make sure you have the quarkus-resteasy-mutiny extension in your project as indicated on https://quarkus.io/guides/getting-started-reactive.

If you are using RESTEasy Reactive it should work OOTB.

Clement
  • 2,817
  • 1
  • 12
  • 11