[ https://issues.apache.org/jira/browse/MYFACES-3695?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Leonardo Uribe resolved MYFACES-3695. ------------------------------------- Resolution: Fixed Fix Version/s: 2.1.11 2.0.17 Assignee: Leonardo Uribe It seems the easiest solution is check if the response has been committed and if not, write the content lenght, otherwise continue. Since the change was done in mojarra, I suppose it is ok to apply it in myfaces too. > 'Cannot set header. Response already committed.' on WebSphere Application > Server 7 and 8 > ---------------------------------------------------------------------------------------- > > Key: MYFACES-3695 > URL: https://issues.apache.org/jira/browse/MYFACES-3695 > Project: MyFaces Core > Issue Type: Bug > Components: JSR-314 > Affects Versions: 2.1.10 > Environment: WebSphere Application Server 7 or 8 > Reporter: Jack van Ooststroom > Assignee: Leonardo Uribe > Fix For: 2.0.17, 2.1.11 > > > When trying to handle a resource using the default implementation of > ResourceHandler, namely ResourceHandlerImpl, a warning message is logged when > running on WebSphere Application Server 7 or 8: > W com.ibm.ws.webcontainer.srt.SRTServletResponse setIntHeader SRVE8094W: > WARNING: Cannot set header. Response already committed. > Looking at the code of ResourceHandlerImpl.handleResourceRequest(FacesContext > context) I found the following snippet: > 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(); > } > } > } > If the resource is small enough and the buffer limit is not reached > everything should be fine (default size seems 2048), however if the resource > is bigger the buffer gets flushed WebSphere Application Server will use > chunked encoding and the httpServletResponse.setContentLength(count) gets > executed after the fact resulting in the mentioned message. Setting the > org.apache.myfaces.RESOURCE_BUFFER_SIZE context parameter is a possible > workaround, but it would be better to avoid this as resource sizes can be > unpredictable. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira