Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NoSuchMethodError: 'reactor.util.context.ContextView reactor.core.publisher.MonoSink.contextView()'

After upgrade Spring Boot version from 2.6.6 to 2.6.7, I'm getting below error while executing web client rest calls. Any idea?

Sample code

public void execute(BiConsumer<ResponseEntity<JsonNode>, Throwable> responseConsumer) {
    WebClient.RequestBodyUriSpec uriSpec = getUriSpec();
    Mono<ResponseEntity<JsonNode>> responseEntityMono = uriSpec
            .uri(this::buildUri)//"localhost:1234")//
            .headers(this::setHeaders)
            .body(insertBody())
            .retrieve().onRawStatus(i -> i == 599,
            response -> response.bodyToMono(String.class)
                .map(body -> new ExternalException(599, body)))
            .toEntity(JsonNode.class);
    CompletableFuture<ResponseEntity<JsonNode>> completableFuture = responseEntityMono.toFuture();
    completableFuture.whenCompleteAsync(responseConsumer);
}
like image 459
Aswath Murugan Avatar asked Jun 11 '26 21:06

Aswath Murugan


2 Answers

Upgrade pom.xml

<dependency>
    <groupId>io.projectreactor</groupId>
    <artifactId>reactor-core</artifactId>
    <version>3.5.3</version>
</dependency>
like image 111
Abhishek Avatar answered Jun 17 '26 21:06

Abhishek


The method that can't be found is in the class MonoSink (in reactor-core project): https://github.com/reactor/reactor-core/blob/main/reactor-core/src/main/java/reactor/core/publisher/MonoSink.java

Since this was an exception you got after upgrading from spring boot version 2.6.6, I guess that the class that can't find it is HttpClientConnect (in project reactor-netty-http). It would be good to have the whole stack exception though.

@jiangjianbo is not wrong saying that you need to update reactor-core to solve this but not to version 3.4.3. It should be at least the version 3.4.17 (That said I would take latest one, which at the time of writing this is 3.4.19). As you can see in version 3.4.16 contextView() was not yet created: https://github.com/reactor/reactor-core/blob/v3.4.16/reactor-core/src/main/java/reactor/core/publisher/MonoSink.java

like image 35
Antonio Lopez Avatar answered Jun 17 '26 23:06

Antonio Lopez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!