2 Replies Latest reply on Feb 7, 2008 8:18 AM by viggo.navarsete

    Caused by: java.lang.IllegalStateException: The window outpu

    viggo.navarsete

      From time to time I get an exception as described in the subject, and I'm really not sure how to handle it. I'm developing a Richfaces portlet, and it's often when I use richfaces components that I get this exception. If I rewrite things to only use standard JSF components it normally works. Any suggestion what could cause such an exception?
      The stacktrace is here:

      Caused by: javax.portlet.faces.BridgeException: Error processing render lifecycle
       at org.ajax4jsf.portlet.ExceptionHandlerImpl.processRenderException(ExceptionHandlerImpl.java:31)
       at org.ajax4jsf.portlet.AjaxPortletBridge.doFacesRequest(AjaxPortletBridge.java:211)
       at javax.portlet.faces.GenericFacesPortlet.doFacesDispatch(GenericFacesPortlet.java:142)
       ... 237 more
      Caused by: javax.faces.FacesException: java.lang.IllegalStateException: The window output stream is already used
       at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:306)
       at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
       at org.ajax4jsf.portlet.AbstractAjaxBridge.render(AbstractAjaxBridge.java:118)
       at org.ajax4jsf.portlet.AjaxPortletBridge.doFacesRequest(AjaxPortletBridge.java:187)
       ... 238 more
      Caused by: java.lang.IllegalStateException: The window output stream is already used
       at org.jboss.portal.portlet.invocation.response.FragmentResponse.getWriter(FragmentResponse.java:181)
       at org.jboss.portal.portlet.impl.jsr168.api.RenderResponseImpl.getWriter(RenderResponseImpl.java:118)
       at org.ajax4jsf.portlet.application.PortletViewHandler.renderView(PortletViewHandler.java:185)
       at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
       at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
       ... 241 more


      and the xhtml file is here (I'm using facelets):
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <f:view xmlns="http://www.w3.org/1999/xhtml"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:a4j="http://richfaces.org/a4j"
       xmlns:rich="http://richfaces.org/rich">
       <a4j:portlet>
       <style>
       .searchResult {
       margin: 0;
       padding: 0;
       border: 0;
       }
       .treeContent {
       width:450px;
       vertical-align:top;
       horizontal-align:left;
       margin: 0;
       padding: 0;
       }
       .treeDetails {
       width:830px;
       vertical-align:top;
       horizontal-align:right;
       margin: 0;
       padding: 0;
       }
       .treeLink {
       text-decoration: none;
       color: black;
       }
       .treeLink:hover {
       text-decoration: underline;
       }
       .summaryGrid {
       width: 100%;
       margin: 0;
       padding: 0;
       border: 0;
       }
       .resultscroller {
       overflow: auto;
       height: 700px;
       }
       .summaryscroller {
       overflow: auto;
       height: 500px;
       }
       .entityIcon {
       vertical-align: middle;
       margin-right: 5px;
       }
       .basicDetails {
       padding-left: 4px;
       }
       .complexDetails {
       margin: 4px;
       }
       .infoMessage {
       color: red;
       }
       .selectedNode {
       background-color:#BED6F8;
       }
       </style>
       <rich:separator height="1" />
       <h:form>
       <rich:panel id="searchInputPanel">
       <f:facet name="header" >
       <f:verbatim>Search input</f:verbatim>
       </f:facet>
       <h:panelGrid columns="3">
       <h:outputText value="Name:" />
       <h:inputText value="#{searchBean.searchString}" />
       <h:commandButton value="Say Hello" action="#{searchBean.search}"/>
       </h:panelGrid>
       </rich:panel>
       <rich:panel id="searchResultPanel" style="borderich:0;" bodyClass="searchResult">
       <h:panelGrid columnClasses="treeContent, treeDetails" columns="2" cellpadding="0" cellspacing="0">
       <rich:panel bodyClass="resultscroller">
       <f:facet name="header">
       <f:verbatim>Search Result</f:verbatim>
       </f:facet>
       <rich:tree switchType="ajax" value="#{searchBean.searchResultNode.data}" var="item" nodeFace="#{item.type}" selectedClass="selectedNode">
       <rich:treeNode highlightedClass="treeLink" type="organizationNode">
       <h:selectBooleanCheckbox value="#{item.selected}">
       <a4j:support event="onclick" actionListener="#{item.selectDetailsForSummary}" reRender="summaryPanel"/>
       </h:selectBooleanCheckbox>
       <a4j:commandLink styleClass="treeLink" reRender="detailsPanel,tbuPanel" actionListener="#{item.lookupDetails}" value="#{item.organizationName}"/>
       </rich:treeNode>
       <rich:treeNode highlightedClass="treeLink" type="entityNode">
       <h:selectBooleanCheckbox value="#{item.selected}">
       <a4j:support event="onclick" actionListener="#{item.selectDetailsForSummary}" reRender="summaryPanel"/>
       </h:selectBooleanCheckbox>
       <a4j:commandLink styleClass="treeLink" reRender="detailsPanel,tbuPanel" actionListener="#{item.lookupDetails}" value="#{item.entityId}"/>
       </rich:treeNode>
       </rich:tree>
       </rich:panel>
       </h:panelGrid>
       </rich:panel>
       </h:form>
       </a4j:portlet>
      </f:view>
      


      I'm running Richfaces 3.1.3.GA.

        • 1. Re: Caused by: java.lang.IllegalStateException: The window o
          viggo.navarsete

          Could this have something to do with nested components needing explicit have id on them? Or nested components at all?

          • 2. Re: Caused by: java.lang.IllegalStateException: The window o
            viggo.navarsete

            I have managed to recreate a scenario where I get the
            "The window output stream is already used" exception. I discovered that if I have two conditions to test for in a rendered attribute I get the exception, but if I just have one it's ok.....strange!!!

            Let me give you some concrete examples:
            This example will throw the exception:

            <h:panelGrid styleClass="basicDetails" columns="2" rendered="#{!empty searchBean.currentSearch.currentEntityDetails && !empty searchBean.currentSearch.currentEntityURL}">


            but this will work:
            <h:panelGrid styleClass="basicDetails" columns="2" rendered="#{!empty searchBean.currentSearch.currentEntityURL}">


            and this will work:
            <h:panelGrid styleClass="basicDetails" columns="2" rendered="#{!empty searchBean.currentSearch.currentEntityDetails}">


            I have also tried to group the two conditions inside some parentheses:
            <h:panelGrid styleClass="basicDetails" columns="2" rendered="#{(!empty searchBean.currentSearch.currentEntityDetails && !empty searchBean.currentSearch.currentEntityURL)}">

            but that doesn't work either....