javaquarkusreactive

Quarkus reactive endpoint "no serializer found"


I am just playing around with Quarkus Reactive endpoints and have some problems with the Jackson Mapper.

my endpoint:

@Path("/myservice")
public class TestRessource {

@GET
@Path("/test")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Uni<Tmp> getFinancialOverviewMobileProducts() {
    return Uni.createFrom().item(new Tmp("Hello!"));
}
}

my Tmp class:

import io.quarkus.runtime.annotations.RegisterForReflection;

@RegisterForReflection
public class Tmp {

private String name;

public Tmp(String name) {
    this.name = name;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}
}

when I execute the endpoint test I get the error:

No serializer found for class io.smallrye.mutiny.operators.uni.builders.UniCreateFromKnownItem and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)

I am confused because the getter and setters are visible.


Solution

  • The dependency/extension quarkus-resteasy-mutiny is missing.

    mvn quarkus:add-extension -Dextensions="io.quarkus:quarkus-resteasy-mutiny"
    

    Or simply try adding this in your pom.xml

    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-resteasy-mutiny</artifactId>
    </dependency>