Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-612

IllegalStateException: Cannot forward after response has been committed

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Invalid
    • Affects Version/s: 1.1.0
    • Fix Version/s: None
    • Component/s: General
    • Labels:
      None
    • Environment:
      Tomcat 5.5.7, Sun JDK 1.5.0, Mozilla 1.7.10 and Linux.

      Description

      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) {
      }

      }

      }

        Attachments

          Activity

            People

            • Assignee:
              manolito Manfred Geiler
              Reporter:
              jeremygreen23 Jeremy Green
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: