Skip navigation.

Why "IllegalStateException: the servlet does not support async operations for this request" is thrown ?

This exception happens when CometD is run in Servlet 3 compliant containers (where the Jetty Continuations make use of the asynchronous features of Servlet 3) and web.xml is misconfigured.

The correct web.xml must have the async-supported element set to true, for example:

<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.server.CometdServlet</servlet-class>
        <async-supported>true</async-supported>
    </servlet>
    <servlet-mapping>
        <servlet-name>cometd</servlet-name>
        <url-pattern>/cometd/*</url-pattern>
    </servlet-mapping>

</web-app>

The async-supported element should be specified for the CometD servlet and for all filters that may be executed before the CometD servlet such as the CrossOriginFilter.

Refer to the Servlet 3 specification for further details.