Hello,
with Tomcat 8.0.32 (and 8.0.28) sometimes the response object is already committed, before the servlet or JSP page is doing anything. I am moving a large legacy application from Tomcat 6 to Tomcat 8 and found, that JSP pages were sometimes returned to the browser without
any HTTP header or HTTP status line.
So I wrote a servlet filter for debugging:

public class JSPDebugFilter implements Filter {

public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest httpReq = (HttpServletRequest) req;
        HttpServletResponse httpResp = (HttpServletResponse) resp;
System.err.println("JSP Debug filter committed " + resp.isCommitted() + " " + httpReq.getRequestURI());

        if (resp.isCommitted()) {
            System.err.println(httpResp);
            (new Throwable("")).printStackTrace();
        }
        chain.doFilter(req, resp);
    }
  ...
}

It shows, that the response is already committed, when this error happens:

JSP Debug filter committed true /myapp/rsetup.jsp
org.apache.catalina.connector.ResponseFacade@a7c4e6b
java.lang.Throwable:
at simbiosys.chemplanner.servlet.JSPDebugFilter.doFilter(JSPDebugFilter.java:30) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)

The problem happens with both HTTP connector and AJP connector. But if I switched from
Connector protocol="HTTP/1.1" to org.apache.coyote.http11.Http11Protocol  ,
it looked like the error was gone. Same for AJP.

But when we did a load test (unfortunately without the filter), something similar happened in rare cases (about 1 out of 1000):

06-Apr-2016 06:28:00.386 SEVERE [ajp-bio-9019-exec-68] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [suppliers] in context with path [/myapp] threw exception java.lang.IllegalStateException: Cannot create a session after the response has been committed at org.apache.catalina.connector.Request.doGetSession(Request.java:2928)

The session is started at the beginning of the method, before anything else is done.

Could the bug be caused by my application or is this a Tomcat bug? Where could I start debugging?

Thanks
    Martin








---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to