Session sporadically hanging on Tomcat 9 on 6.10.7

Received the following stack trace after deploying a Cuba app to Tomcat 9 running on Windows Server 2012R2:

09-Apr-2019 09:32:11.668 SEVERE [ajp-nio-8011-exec-8] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [app_servlet] in context with path [...] threw exception
java.lang.UnsupportedOperationException: HTTP upgrade is not supported by this protocol
    at org.apache.coyote.AbstractProcessor.doHttpUpgrade(
    at org.apache.coyote.AbstractProcessor.action(
    at org.apache.coyote.Request.action(
    at org.apache.catalina.connector.Request.upgrade(
    at org.apache.catalina.connector.RequestFacade.upgrade(
    at org.apache.tomcat.websocket.server.UpgradeUtil.doUpgrade(
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(
    at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(
    at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(
    at org.springframework.web.filter.CompositeFilter.doFilter(
    at com.haulmont.cuba.web.sys.CubaHttpFilter.doFilter(
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(
    at org.apache.catalina.core.StandardWrapperValve.invoke(
    at org.apache.catalina.core.StandardContextValve.invoke(
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(
    at org.apache.catalina.core.StandardHostValve.invoke(
    at org.apache.catalina.valves.ErrorReportValve.invoke(
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(
    at org.apache.catalina.core.StandardEngineValve.invoke(
    at org.apache.catalina.connector.CoyoteAdapter.service(
    at org.apache.coyote.ajp.AjpProcessor.service(
    at org.apache.coyote.AbstractProcessorLight.process(
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$ Source)
    at org.apache.tomcat.util.threads.TaskThread$
    at Source)

I haven’t been able to reproduce the error consistently, but, when it occurs, it hangs the current session indefinitely and eventually the application runs out of memory.
After some digging in the Tomcat source, I see that the WsFilter class doesn’t exist in 8.5. In 9 the final stacktrace line in AbstractProcessor (ironically) looks like:

protected void doHttpUpgrade(UpgradeToken upgradeToken) {
    // Should never happen
    throw new UnsupportedOperationException(

Whatever implementation of AbstractProcessor is running (my guess is StreamProcessor) must not override this.

Any chance of a workaround? Or am I stuck downgrading Tomcat to 8.5? FWIW this is the only issue we’ve noticed with Cuba 6.10 on Tomcat 9.


Could you share your web.xml file? Did you try to deploy a solution to Tomcat 9 without com.haulmont.addon.saml application component?

The project that this is extending does use the SAML addon, but this one does not. This project’s web.xml did not declare that as an app component. I’m guessing it should and I’ve added it and restarted.

Worth mentioning this is an IIS redirect to Tomcat.

I see this code at the start of Tomcat’s WsFilter:

// This filter only needs to handle WebSocket upgrade requests
if (!sc.areEndpointsRegistered() ||
        !UpgradeUtil.isWebSocketUpgradeRequest(request, response)) {
    chain.doFilter(request, response);

I can only imagine that an AJP or HTTP 2 request is making it to this point and not meeting these conditions, after which, the WsFilter tries to upgrade the request, which AJP and HTTP 2 don’t support. I’m currently sitting with a breakpoint right after that that block, I’ll update if I catch anything.

And as I’m typing I’ve caught the issue. A web socket upgrade request to /PUSH gets to the WsFilter. It’s over AJP and the AjpProcessor does not support HTTP upgrade.

I’ve checked Tomcat 9 with Platform 6.10 and everything runs OK. Unfortunately, I cannot reproduce your setup.

The problem could be related with async property of servlets and filters. WebSocket upgrade requires that all HTTP filters marked as <async-supported>true</async-supported>. But, it is just a guess.

In such a complex case I’d recommend that you switch to Long Polling transport instead of WebSocket using cuba.web.pushLongPolling application property of Web Client:

cuba.web.pushLongPolling = true