I have started noticing a significant number of the following messages being logged:
Jul 22, 2010 9:35:00 AM com.sun.faces.context.flash.ELFlash setCookie
WARNING: JSF1095: The response was already committed by the time we tried to set the outgoing cookie for the flash. Any values stored to the flash will not be available on the next request.
They do not appear to impact the availability of the message that I am sticking into the flash in as much as the message is present when the page is refreshed. It is also not consistent as to when this error occurs - I would roughly guess that it happens 50% of the time, but it does not seem predictable in any way (the exact same steps reproduce the issue intermittently). The code that puts the message into the flash is as follows:
final FacesContext context = FacesContext.getCurrentInstance();
final Flash flash = context.getExternalContext().getFlash();
flash.put( "commandExceptionMessage", commandException.getPublicMessage() );
This call is made during an ActionEvent, just prior to returning the navigation result which always includes "?faces-redirect=true&includeViewParams=true" since I am using viewParameters to initialize backing bean values. When the redirected page is rendered, the value I have set in the flash for the FLASH_MESSAGE_ID is present and displayed. However I often see the error above in the log.
The usage of this in the page is as simple as can be:
<h:outputText value="#{flash.commandExceptionMessage}" rendered="#{flash.commandExceptionMessage != null}"/>
Additionally I am seeing some rather odd behavior with the flash while using <h:link> with View Parameters for navigation.
After adding a value to the flash, if I then use <h:link> to navigate to another page and then use an <h:link> to return to the previous page I will see the previously added message. This does not occur when I submit the form and use POST-REDIRECT-GET for navigation, only with pure GET requests.
Sometimes I will see the error above when I link to a new page from the page that invoked the action that resulted in the addition of the message to the flash (both in cases where I had gotten the above error on the initial form submit/re-render and in cases where I did not). When this occurs, If I follow 2 links that eventually lead back to the page where I am displaying the message conditionally, I will see the message that was originally added to the flash 4 requests back (4 GET requests -- the initial PRG counting as one). I imagine that the flash is determining how long to store contents based on the standard JSF POSTBACK model, which is resulting in strange impedence mismatches when used with the new View Parameters and plain GET methodology.
I found a couple posts about this error, but in all cases the developers simply gave up and retreated to using Session scoped Objects. I would prefer to see a solution to the issue. Has anyone seen this and gotten past it?
Thanks,
--Zack