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

5

7

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);
}
Vikkivikky answered 24/4, 2022 at 14:11 Comment(0)
E
7

Upgrade pom.xml

<dependency>
    <groupId>io.projectreactor</groupId>
    <artifactId>reactor-core</artifactId>
    <version>3.5.3</version>
</dependency>
Escapade answered 2/3, 2023 at 10:12 Comment(2)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Oteliaotero
The newer versions of spring boot require the more recent version of reactor lib, otherwise, it causes this error, I didn't investigate the details but updating versions fixes the issue. Besides errors, it uses all connections pool and transactions across application. So it hangs and everything is languid. The proper version could be found here: spring dependenciesBarranca
T
5

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

Thallium answered 21/6, 2022 at 21:17 Comment(0)
C
4

Upgrade you pom.xml

<dependency>
    <groupId>io.projectreactor</groupId>
    <artifactId>reactor-core</artifactId>
    <version>3.4.3</version>
</dependency>
Celebrity answered 25/4, 2022 at 7:44 Comment(2)
Did you mean to downgrade reactor dependency instead of upgrade - because the included version is 3.4.10? Also doesn't seem to solve the issue for me.Spratt
Fyi, fixed for me with spring boot 2.7.1 when setting reactor-core to 3.4.19Spratt
M
0

You've reload Maven project.

Right click on Maven -> Reload project. After that rerun your app.

Montgolfier answered 8/3, 2023 at 22:19 Comment(0)
Y
0

After upgrading spring boot 3.1.4 version, i need to exclude reactor core and add again with downgraded version 3.4.9. Here is the pom: com.azure.spring spring-cloud-azure-starter 4.0.0

        <dependency>
            <groupId>com.azure.spring</groupId>
            <artifactId>spring-cloud-azure-starter-storage-blob</artifactId>
            <version>4.0.0</version>
            <exclusions>
                <exclusion>
                    <groupId>io.projectreactor</groupId>
                    <artifactId>reactor-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-core</artifactId>
            <version>3.4.19</version>
        </dependency>
Yahwistic answered 6/11, 2023 at 7:29 Comment(2)
what is this? an answer to the question? a different question and its answer?Ratha
This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From ReviewQuod

© 2022 - 2024 — McMap. All rights reserved.