''producer' type is unknown to ReactiveAdapterRegistry (WebFlux handler)

I have the following route in my application

@Bean
public RouterFunction<ServerResponse> route(UserHandler handler) {
    return RouterFunctions.route(RequestPredicates.POST("/users"), handler::signup);
}

which is handled by the following method

public Mono<ServerResponse> signup(ServerRequest request) {
    return request
            .bodyToMono(User.class)
            .map(user -> {
                user.setPassword(encoder.encode(user.getPassword()));
                return user;
            })
            .flatMap(repository::save)
            .map(user -> tokenService.create(user.getId()))
            .map(TokenDto::new)
            .flatMap(tokenDto -> ServerResponse.ok().body(tokenDto, TokenDto.class));
}

When I issue a valid request to the endpoint, the following error is logged

'producer' type is unknown to ReactiveAdapterRegistry

Having investigated the issue with a debugger, I see that my handler's signup method completes successfully, so I'm assuming the router doesn’t like the return value, but I'm not sure why?



Solution 1:[1]

try to change tokenDto to Mono.just(tokenDto) it worked for me. I got the same problem just now.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Connar John