Tomcat ERROR: java.lang.IllegalStateException: call [asyncPostProcess ()] is not valid for a request with an Async state [START]

in an attempt to get this simple demo on tomcat 7.0.37: https://github.com/cometd/cometd-tutorials/tree/master/client-hello

I modified web.xml to support asynchronous calling (cometD is used with a long poll).

<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <servlet> <servlet-name>cometd</servlet-name> <servlet-class>org.cometd.annotation.AnnotationCometdServlet</servlet-class> <init-param> <param-name>transports</param-name> <param-value>org.cometd.websocket.server.WebSocketTransport</param-value> </init-param> <init-param> <param-name>services</param-name> <param-value>org.cometd.tutorials.ClientHelloService</param-value> </init-param> <load-on-startup>1</load-on-startup> <async-supported>true</async-supported> </servlet> <servlet-mapping> <servlet-name>cometd</servlet-name> <url-pattern>/cometd/*</url-pattern> </servlet-mapping> <filter> <filter-name>cross-origin</filter-name> <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class> <async-supported>true</async-supported> </filter> <filter-mapping> <filter-name>cross-origin</filter-name> <url-pattern>/cometd/*</url-pattern> </filter-mapping> <filter> <filter-name>continuation</filter-name> <filter-class>org.eclipse.jetty.continuation.ContinuationFilter</filter-class> <async-supported>true</async-supported> </filter> <filter-mapping> <filter-name>continuation</filter-name> <url-pattern>/cometd/*</url-pattern> </filter-mapping> </web-app> 

If I press a button to send a message to the server, I get the following error:

 java.lang.IllegalStateException: Calling [asyncPostProcess()] is not valid for a request with Async state [STARTED] at org.apache.coyote.AsyncStateMachine.asyncPostProcess(AsyncStateMachine.java:204) at org.apache.coyote.AbstractProcessor.asyncPostProcess(AbstractProcessor.java:116) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:593) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1686) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) 

Perhaps someone can bring light to this stack?

+4
source share
3 answers

Make sure you set true for all your filters. See http://cometd.org/node/106

The supported asynchronous element must be specified for the CometD servlet and for all filters that can be executed before the CometD servlets, such as CrossOriginFilter.

I was getting this problem because I had one recently added filter that had nothing to do with a comet that lacked this tag. Adding a tag fixes the problem.

0
source

If you use frameworks such as struts, take care of dynamically added filters, except for filters configured in web.xml. http://blog.163.com/pilgrim_yang/blog/static/556314812014218977633/

0
source

Looks like this bug. This has been fixed in Tomcat 7.0.43.

0
source

Source: https://habr.com/ru/post/1483768/


All Articles