ICEfaces-EE
  1. ICEfaces-EE
  2. IPCK-431

Cannot set header. Response already committed. on WAS 7 and 8

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: EE-3.2.0.BETA
    • Fix Version/s: EE-3.2.0.GA
    • Component/s: None
    • Labels:
      None
    • Environment:
      WebSphere Application Server 7/8, ICEfaces 3
    • Affects:
      Documentation (User Guide, Ref. Guide, etc.), Compatibility/Configuration
    • Workaround Description:
      Hide
      When experiencing these warnings, depending on the library being used add one of the following snippets to the ICEfaces application's web.xml.

      Mojarra:

          <context-param>
              <param-name>com.sun.faces.resourceBufferSize</param-name>
              <param-value>524288</param-value>
          </context-param>

      MyFaces:

          <context-param>
              <param-name>org.apache.myfaces.RESOURCE_BUFFER_SIZE</param-name>
              <param-value>524288</param-value>
          </context-param>

      Note that the value can be changed as desired.
      Show
      When experiencing these warnings, depending on the library being used add one of the following snippets to the ICEfaces application's web.xml. Mojarra:     <context-param>         <param-name>com.sun.faces.resourceBufferSize</param-name>         <param-value>524288</param-value>     </context-param> MyFaces:     <context-param>         <param-name>org.apache.myfaces.RESOURCE_BUFFER_SIZE</param-name>         <param-value>524288</param-value>     </context-param> Note that the value can be changed as desired.

      Description

      The following warning can appear in the logs when running a stock ICEfaces application on WAS 7/8:

      W com.ibm.ws.webcontainer.srt.SRTServletResponse setIntHeader SRVE8094W: WARNING: Cannot set header. Response already committed.

        Activity

        Hide
        Jack Van Ooststroom added a comment -

        This is possibly due to Mojarra. I can reproduce it with Mojarra 2.1.17 as well. The last line on the ICEfaces end that gets executed is:

        resourceHandler.handleResourceRequest(facesContext);

        Down the line, Mojarra does the following eventually:

        for (int thisRead = resourceChannel.read(buf), totalWritten = 0;
        thisRead != -1;
        thisRead = resourceChannel.read(buf)) {

        buf.rewind();
        buf.limit(thisRead);
        do

        { totalWritten += out.write(buf); }

        while (totalWritten < size);
        buf.clear();
        size += thisRead;

        }

        extContext.setResponseContentLength(size);

        Here you can see that it first tries to write the contents and at the end it sets the Content-Length. This should be the other way around. As a simple test I removed the last line and tested again. The warnings went away.

        Show
        Jack Van Ooststroom added a comment - This is possibly due to Mojarra. I can reproduce it with Mojarra 2.1.17 as well. The last line on the ICEfaces end that gets executed is: resourceHandler.handleResourceRequest(facesContext); Down the line, Mojarra does the following eventually: for (int thisRead = resourceChannel.read(buf), totalWritten = 0; thisRead != -1; thisRead = resourceChannel.read(buf)) { buf.rewind(); buf.limit(thisRead); do { totalWritten += out.write(buf); } while (totalWritten < size); buf.clear(); size += thisRead; } extContext.setResponseContentLength(size); Here you can see that it first tries to write the contents and at the end it sets the Content-Length. This should be the other way around. As a simple test I removed the last line and tested again. The warnings went away.
        Hide
        Ken Fyten added a comment -

        QA reports that the same warnings are logged with MyFaces 2.1.10:

        Showcase (MyFaces JSF):

        ICEsoft Technologies Inc.
        ICEpush-EE 3.2.0.GA
        Build number: 6
        Revision: 33386
        [1/19/13 22:00:23:061 MST] 00000046 srt W com.ibm.ws.webcontainer.srt.SRTServletResponse setIntHeader WARNING: Cannot set header. Response already committed.
        [1/19/13 22:00:23:071 MST] 0000004b srt W com.ibm.ws.webcontainer.srt.SRTServletResponse setIntHeader WARNING: Cannot set header. Response already committed.

        Show
        Ken Fyten added a comment - QA reports that the same warnings are logged with MyFaces 2.1.10: Showcase (MyFaces JSF): ICEsoft Technologies Inc. ICEpush-EE 3.2.0.GA Build number: 6 Revision: 33386 [1/19/13 22:00:23:061 MST] 00000046 srt W com.ibm.ws.webcontainer.srt.SRTServletResponse setIntHeader WARNING: Cannot set header. Response already committed. [1/19/13 22:00:23:071 MST] 0000004b srt W com.ibm.ws.webcontainer.srt.SRTServletResponse setIntHeader WARNING: Cannot set header. Response already committed.
        Hide
        Jack Van Ooststroom added a comment -

        Looking at the source, namely ResourceHandlerImpl of MyFaces, it seems to be doing a similar thing as Mojarra:

        try
        {
        InputStream in = resource.getInputStream();
        OutputStream out = httpServletResponse.getOutputStream();
        //byte[] buffer = new byte[_BUFFER_SIZE];
        byte[] buffer = new byte[this.getResourceBufferSize()];

        try

        { int count = pipeBytes(in, out, buffer); //set the content lenght httpServletResponse.setContentLength(count); }

        finally
        {
        try

        { in.close(); }

        finally

        { out.close(); }

        }
        }

        Looks like the bytes of the Entity-Body are first written then the Content-Length is set after the fact.

        Show
        Jack Van Ooststroom added a comment - Looking at the source, namely ResourceHandlerImpl of MyFaces, it seems to be doing a similar thing as Mojarra: try { InputStream in = resource.getInputStream(); OutputStream out = httpServletResponse.getOutputStream(); //byte[] buffer = new byte [_BUFFER_SIZE] ; byte[] buffer = new byte [this.getResourceBufferSize()] ; try { int count = pipeBytes(in, out, buffer); //set the content lenght httpServletResponse.setContentLength(count); } finally { try { in.close(); } finally { out.close(); } } } Looks like the bytes of the Entity-Body are first written then the Content-Length is set after the fact.
        Hide
        Ken Fyten added a comment -

        MyFaces 2.1.10 has a new context param which is a workaround for this issue:

        https://issues.apache.org/jira/browse/MYFACES-3636

        Show
        Ken Fyten added a comment - MyFaces 2.1.10 has a new context param which is a workaround for this issue: https://issues.apache.org/jira/browse/MYFACES-3636
        Hide
        Ken Fyten added a comment -

        So, we will document these issues as Known Issues in the Release Notes, since they are rooted in the way the MyFaces and Mojarra JSF libs are working.

        We will also need to open JIRAs for these for Mojarra and MyFaces.

        Show
        Ken Fyten added a comment - So, we will document these issues as Known Issues in the Release Notes, since they are rooted in the way the MyFaces and Mojarra JSF libs are working. We will also need to open JIRAs for these for Mojarra and MyFaces.
        Hide
        Jack Van Ooststroom added a comment -
        Show
        Jack Van Ooststroom added a comment - The following issues have been opened: Mojarra: http://java.net/jira/browse/JAVASERVERFACES-2739 MyFaces: https://issues.apache.org/jira/browse/MYFACES-3695

          People

          • Assignee:
            Jack Van Ooststroom
            Reporter:
            Jack Van Ooststroom
          • Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: