user15276776
user15276776

Reputation:

'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?

Upvotes: 3

Views: 4386

Answers (2)

Connar John
Connar John

Reputation: 1

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

Upvotes: 0

bobxwang
bobxwang

Reputation: 56

I have the same problem with you, the same error. Finally I change the code using bodyValue method not body(T,Class),you can try this: ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).bodyValue(tokenDto)

Upvotes: 4

Related Questions