I have a webapp running in Tomcat 6.0.20.

One of my testers caused this to appear in the logs:

May 11, 2010 2:23:14 PM org.apache.jasper.runtime.JspFactoryImpl
internalGetPageContext
SEVERE: Exception initializing page context
java.lang.IllegalStateException: Cannot create a session after the response has
been committed
        at
org.apache.catalina.connector.Request.doGetSession(Request.java:2313)
        at org.apache.catalina.connector.Request.getSession(Request.java:2074)
        at
org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)
        at
javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)
        at
org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:544)
        at
org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:493)
        at
org.apache.jasper.runtime.PageContextImpl._initialize(PageContextImpl.java:146)
        at
org.apache.jasper.runtime.PageContextImpl.initialize(PageContextImpl.java:124)
        at
org.apache.jasper.runtime.JspFactoryImpl.internalGetPageContext(JspFactoryImpl.java:107)
        at
org.apache.jasper.runtime.JspFactoryImpl.getPageContext(JspFactoryImpl.java:63)
        at
org.apache.jsp.unexpectedErrors_jsp._jspService(unexpectedErrors_jsp.java:74)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
        at
org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
        at
org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
        at
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
        at
org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:621)
        at
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:820)
        at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
        at org.apache.jsp.auditLog_jsp._jspService(auditLog_jsp.java:422)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
com.eaglecreektech.expedience.provisioning.web.servletFilters.AuthFilter.doFilter(AuthFilter.java:159)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
com.eaglecreektech.expedience.provisioning.web.servletFilters.RequestVolumeFilter.doFilter(RequestVolumeFilter.java:141)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
com.eaglecreektech.expedience.provisioning.web.servletFilters.StartupCheckFilter.doFilter(StartupCheckFilter.java:68)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
        at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
        at java.lang.Thread.run(Unknown Source)

And I'm a little baffled.
Here is my best guess at what happened:

The page in question (auditLog.jsp) is generating results, and sending
them back to the browser as they arrive, by flushing the buffers back
to the browser ever so often.  It can take a long time to complete the
page.  I think that the user closed their browser, or navigated away
from the page before the page was complete - so the next time we tried
to push results back, we got some sort of session closed exception.
Which is expected.

What happened next was the exception was caught by this (tomcat
generated) code in auditLog_jsp.java:

 catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null)
_jspx_page_context.handlePageException(t);    // <---- this is
auditLog_jsp.java:422
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }


Tomcat then redirected to my error page (unexpectedErrors.jsp) - here
is the code corresponding to the next hit on my code in the stack
trace:

public void _jspService(HttpServletRequest request,
HttpServletResponse response)
        throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    Throwable exception =
org.apache.jasper.runtime.JspRuntimeLibrary.getThrowable(request);
    if (exception != null) {
      response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      response.setContentType("text/html; charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request,
response,   // <--- This is unexpectedErrors_jsp.java:74
                        "/unexpectedErrors.jsp", true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;


So, it looks like Tomcat generated an error by calling
getPageContext(...) after the session was closed.

My code in unexpectedErrors.jsp checks the state of
"response.isCommitted()" before deciding what course of action to
take, but it didn't even get that far, it threw this new exception
before it even got to my code in unexpectedErrors_jsp.java

Is there anything I can do to make this not happen?  I don't care
about the error, other than I don't want it to appear in the log file
as a "SEVERE: Exception " because that generates support tickets....

Thanks,

Dan

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

Reply via email to