quarkusmutiny

quarkus: reactive mutiny returns object Uni reference instead of string value


I'm getting this resource when I'm reaching my endpoint:

$ curl http://localhost:8080/hello
io.smallrye.mutiny.operators.uni.builders.UniCreateFromKnownItem@255ef91

This is my code:

@Path("/hello")
@AllArgsConstructor
public class GreetingResource {

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public Uni<String> hello() {
        return Uni.createFrom().item("item1");
    }
}

Those are my quarkus project dependencies:

<dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>${quarkus.platform.group-id}</groupId>
        <artifactId>${quarkus.platform.artifact-id}</artifactId>
        <version>${quarkus.platform.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-neo4j</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-resteasy-jackson</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-resteasy</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-arc</artifactId>
    </dependency>
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <version>${lombok.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-mutiny</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-junit5</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.rest-assured</groupId>
      <artifactId>rest-assured</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

Any ideas?


Solution

  • RESTEasy, and the quarkus-resteasy extension, don't know what Uni is and cannot serialize it properly.

    If you can, I'd advice you to switch to quarkus-resteasy-reactive (and quarkus-resteasy-reactive-jackson) if you're using reactive types.

    If you need the classic RESTEasy, add quarkus-resteasy-mutiny to your dependencies.