Search code examples
httpdojoglassfishcomet

Cometd dojo application - HTTP 408 with glassfish


I configured and developped an intranet application that combines: spring 3.0.5 (including security) + CometD 2.3.1.

In order to setup cometd, I referred to : http://docs.cometd.org/2.4.3/reference/#java_server_services_integration_spring

When I run my application in jetty, everything works fine. But when I try to run it in a glassfish v2, I'm "randomly" getting HTTP 408 . Error in server.log:

    [#|2012-11-02T15:43:50.428+0100|SEVERE|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=17;_ThreadName=httpSSLWorkerThread-9000-0;_RequestID=eb9ebc97-ac0f-48fe-8793-cfc9fd3e7b3a;|StandardWrapperValve[default]: PWC1406: Servlet.service() for servlet default threw exception
java.lang.IllegalStateException
    at org.apache.coyote.tomcat5.CoyoteResponseFacade.sendError(CoyoteResponseFacade.java:433)
    at javax.servlet.http.HttpServletResponseWrapper.sendError(HttpServletResponseWrapper.java:141)
    at org.springframework.security.web.context.SaveContextOnUpdateOrErrorResponseWrapper.sendError(SaveContextOnUpdateOrErrorResponseWrapper.java:54)
    at org.apache.catalina.servlets.DefaultServlet.serveResource(DefaultServlet.java:740)
    at org.apache.catalina.servlets.DefaultServlet.doGet(DefaultServlet.java:384)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
    at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:368)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)

And from the IE client perspective, my cometD connectivity is unstable:

13:16:16 - CometD Connection Established
13:16:16 - CometD Connection Broken
13:16:17 - CometD Connection Established
13:16:17 - CometD Connection Broken
13:16:20 - CometD Connection Established
13:16:20 - CometD Connection Broken
13:16:21 - CometD Connection Established
13:16:21 - CometD Connection Broken
13:16:22 - CometD Connection Established
13:16:23 - CometD Connection Broken

but despite error message, the cometd connectivity works: subscribe actions are OK and notifications are succesfully received from the server.

Nota: I deployed the sample dojo-chat application (that I took as a model) in the same glassfish domain and it's working fine!

What could have I missed?


Solution

  • In fact I found the answer in the cometD samples WAR (in the web.xml file):

    <!-- Portability Filter, needed only to run on non Jetty or non Servlet-3.0 containers -->
    <filter>
        <filter-name>continuation</filter-name>
        <filter-class>org.eclipse.jetty.continuation.ContinuationFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>continuation</filter-name>
        <url-pattern>/cometd/*</url-pattern>
    </filter-mapping>
    

    This filter was not in my web.xml. The point I don't understand is the reason why the demo application was working fine (with the same servlet container) whereas the filter was commented?!?