Calling [asyncError()] is not valid for a request with Async state [MUST_DISPATCH]
Asked Answered
K

4

18

env:
case 1:
client : springboot(1.5.12.RELEASE) + spring-boot-admin-starter-client 1.5.7

admin: springboot(2.1.1.RELEASE) + spring-boot-admin-starter-server 2.1.1

when i run client,and refresh admin app. the error is "Calling [asyncError()] is not valid for a request with Async state [MUST_DISPATCH]";

case2:
(2.1.1.RELEASE) Both the client and the server use the same version and have the same error.

Detailed errors are as follows:

2018-12-04 11:10:40.129 ERROR 2572 --- [nio-9090-exec-5] o.a.catalina.connector.CoyoteAdapter     : Exception while processing an asynchronous request

java.lang.IllegalStateException: Calling [asyncError()] is not valid for a request with Async state [MUST_DISPATCH]
    at org.apache.coyote.AsyncStateMachine.asyncError(AsyncStateMachine.java:440) ~[tomcat-embed-core-9.0.13.jar:9.0.13]
    at org.apache.coyote.AbstractProcessor.action(AbstractProcessor.java:512) [tomcat-embed-core-9.0.13.jar:9.0.13]
    at org.apache.coyote.Request.action(Request.java:430) ~[tomcat-embed-core-9.0.13.jar:9.0.13]
    at org.apache.catalina.core.AsyncContextImpl.setErrorState(AsyncContextImpl.java:382) ~[tomcat-embed-core-9.0.13.jar:9.0.13]
    at org.apache.catalina.connector.CoyoteAdapter.asyncDispatch(CoyoteAdapter.java:239) ~[tomcat-embed-core-9.0.13.jar:9.0.13]
    at org.apache.coyote.AbstractProcessor.dispatch(AbstractProcessor.java:241) [tomcat-embed-core-9.0.13.jar:9.0.13]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:53) [tomcat-embed-core-9.0.13.jar:9.0.13]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:791) [tomcat-embed-core-9.0.13.jar:9.0.13]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1417) [tomcat-embed-core-9.0.13.jar:9.0.13]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.13.jar:9.0.13]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_162]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_162]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.13.jar:9.0.13]
    at java.lang.Thread.run(Unknown Source) [na:1.8.0_162]
Kronstadt answered 4/12, 2018 at 3:17 Comment(1)
I'm having a similar issue. I'm combining both SBA and Eureka Admin Server in one spring service. After getting it all to work, when a client registers with Eureka, it also shows up in SBA, but the exact same exception is thrown and I have no clue why.Bacteroid
F
4

Try to switch on JETTY, it has helped me.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <exclusions>
        <exclusion>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <groupId>org.springframework.boot</groupId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
Foamflower answered 12/2, 2019 at 11:16 Comment(4)
It is not clear what the code has to do with your answer.Shipway
I mean that as an alternative to using reactive setup you can just use JETTY container.Foamflower
this worked for me. I am still curious whats wrong with tomcat.Zigzag
why i have to do thisNanine
E
3

SBA-UI is using some long polling, when the browser closes the connection and the server tries to write some data on it the above exception is logged. All of it is quite normal. It shouldn't affect the application. For more infformation: https://github.com/spring-projects/spring-boot/issues/15057

Ellette answered 22/12, 2018 at 22:1 Comment(0)
C
0

Actually there is a simple solution: Just don't use the Tomcat servlet container but run the admin server in a reactive setup, like:

@SpringBootApplication
@EnableAdminServer
public class AdminServer {
    public static void main(String[] args) {
        new SpringApplicationBuilder(AdminServer.class)
        .web(WebApplicationType.REACTIVE)
        .run(args);
    }
}

This way I don't get any errors.

Carboy answered 17/1, 2019 at 17:51 Comment(1)
This doesn't work if I have spring security in classpathTupelo
N
0

As posted on https://github.com/codecentric/spring-boot-admin/issues/1039#issuecomment-562910061, you just need to change the version of tomcat like this (in your pom.xml):

    <properties>
        <tomcat.version>9.0.54</tomcat.version>
    </properties>
Nanine answered 9/11, 2021 at 9:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.