java.lang.IllegalStateException: Cannot forward after response has been committed

Apache's JIRA Issue Tracker | Jeremy Green | 1 decade ago
  1. 0

    [MYFACES-612] IllegalStateException: Cannot forward after response has been committed - ASF JIRA

    apache.org | 11 months ago
    java.lang.IllegalStateException: Cannot forward after response has been committed
  2. 0

    Rapid, multiple clicks on the h:commandButton in the test case given below produce an IllegalStateException and a blank response about 10% of the time. The JSF state-saving method can be client or server. A blank page is sometimes returned even if the clicks are not rapid. The Sun JSF RI 1.1_01 shows the same problem: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6326655 The stack trace is: SEVERE: Servlet.service() for servlet Faces Servlet threw exception java.lang.IllegalStateException: Cannot forward after response has been committed at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:314) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302) at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:415) at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:234) at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:300) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:95) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Thread.java:595) Here is the test case: index.jsp: <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <html> <head></head> <body> <f:view> <h:form> <p> <h:commandButton value="Submit" /> </p> <p> <h:graphicImage value="image.png" /> </p> </h:form> </f:view> </body> </html> SlowServlet.java, mapped to image.png in web.xml: public class SlowServlet extends HttpServlet { protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { BufferedImage image; OutputStream os; image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB); os = resp.getOutputStream(); resp.setContentType("image/png"); try { Thread.sleep(1000); } catch (InterruptedException e) { throw new ServletException(e); } try { ImageIO.write(image, "png", os); os.close(); } catch (IOException e) { } } }

    Apache's JIRA Issue Tracker | 1 decade ago | Jeremy Green
    java.lang.IllegalStateException: Cannot forward after response has been committed
  3. 0

    Rapid, multiple clicks on the h:commandButton in the test case given below produce an IllegalStateException and a blank response about 10% of the time. The JSF state-saving method can be client or server. A blank page is sometimes returned even if the clicks are not rapid. The Sun JSF RI 1.1_01 shows the same problem: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6326655 The stack trace is: SEVERE: Servlet.service() for servlet Faces Servlet threw exception java.lang.IllegalStateException: Cannot forward after response has been committed at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:314) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302) at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:415) at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:234) at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:300) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:95) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Thread.java:595) Here is the test case: index.jsp: <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <html> <head></head> <body> <f:view> <h:form> <p> <h:commandButton value="Submit" /> </p> <p> <h:graphicImage value="image.png" /> </p> </h:form> </f:view> </body> </html> SlowServlet.java, mapped to image.png in web.xml: public class SlowServlet extends HttpServlet { protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { BufferedImage image; OutputStream os; image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB); os = resp.getOutputStream(); resp.setContentType("image/png"); try { Thread.sleep(1000); } catch (InterruptedException e) { throw new ServletException(e); } try { ImageIO.write(image, "png", os); os.close(); } catch (IOException e) { } } }

    Apache's JIRA Issue Tracker | 1 decade ago | Jeremy Green
    java.lang.IllegalStateException: Cannot forward after response has been committed
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Rewrite tries to forward even if response has already been committed

    GitHub | 3 years ago | chkal
    java.lang.IllegalStateException: Cannot forward after response has been committed
  6. 0

    Servlet springAwareVaadinServlet is currently unavailable

    GitHub | 2 years ago | sbradeen
    java.lang.IllegalStateException: Cannot forward after response has been committed

    1 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalStateException

      Cannot forward after response has been committed

      at org.apache.catalina.core.ApplicationDispatcher.doForward()
    2. Glassfish Core
      ApplicationDispatcher.forward
      1. org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:314)
      2. org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
      2 frames