Does anyone know what causes this error?

UI Components for JSF
Post Reply
burferd
Posts: 234
Joined: 01 May 2010, 16:15

18 Nov 2011, 01:05

Using PrimeFaces 3.0M4, Glassfish 3.2, Mojarra 2.1.3, NetBeans 6.9.1

I am trying to figure out why I keep getting the error listed below.
I have reduced the page to 2 composite components.
One is a header and the other is a menu.
The problem seems to be related to the menu part.

I believe the problem is related to the menu, although I cannot consistently reproduce the error without a second composite component on the page.
I am using a <p:toolBar> with <p:menuButton> components, since there appears to be a problem with the <p:menuBar> not rendering hotizontally.
If I include more than one <p:menuButton> component, I consistently get the following error.
If I remove the second <p:menuButton> component, I do not get the error.

Any help is appreciated.
Thanks.

Error in server log:

Code: Select all

SEVERE: Error Rendering View[/HomePage.xhtml]
java.lang.IllegalStateException: PWC3999: Cannot create a session after the response has been committed
        at org.apache.catalina.connector.Request.doGetSession(Request.java:2880)
        at org.apache.catalina.connector.Request.getSession(Request.java:2577)
        at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:920)
        at com.sun.faces.context.ExternalContextImpl.getSession(ExternalContextImpl.java:155)
        at com.sun.faces.renderkit.ServerSideStateHelper.writeState(ServerSideStateHelper.java:175)
        at com.sun.faces.renderkit.ResponseStateManagerImpl.writeState(ResponseStateManagerImpl.java:122)
        at com.sun.faces.application.StateManagerImpl.writeState(StateManagerImpl.java:166)
        at com.sun.faces.application.view.WriteBehindStateWriter.flushToWriter(WriteBehindStateWriter.java:225)
        at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:418)
        at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
        at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
        at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
        at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
        at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
        at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
        at java.lang.Thread.run(Thread.java:662)

INFO: Exception when handling error trying to reset the response.
java.lang.IllegalStateException: PWC3999: Cannot create a session after the response has been committed
        at org.apache.catalina.connector.Request.doGetSession(Request.java:2880)
...
Here is the code for the menu composite component - it is pretty much a clone of the showcase example:

Code: Select all

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:p="http://primefaces.org/ui">

    <!-- INTERFACE -->
    <cc:interface>
    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>
        <p:toolbar style="overflow: visible !important; z-index: 20;" >
            <p:toolbarGroup align="left" >

                <p:menuButton value="File" >
                    <p:menuitem value="New" icon="ui-icon ui-icon-contact" />
                    <p:menuitem value="Open" url="#" />
                    <p:menuitem value="Quit" url="#" />
                </p:menuButton>
            </p:toolbarGroup>

            <p:toolbarGroup align="left" >
                <p:menuButton value="Item 1" >
                    <p:menuitem value="New1" icon="ui-icon ui-icon-contact" />
                    <p:menuitem value="Open1" />
                    <p:menuitem value="Quit1" />
                </p:menuButton >
            </p:toolbarGroup>

            <p:toolbarGroup align="left" >
                <p:commandButton type="push" value="New" image="ui-icon-folder-open"/>
                <p:commandButton type="push" value="Open" image="ui-icon-folder-open"/>

                <p:separator />

                <p:commandButton type="push" title="Save" image="ui-icon-disk"/>
                <p:commandButton type="push" title="Delete" image="ui-icon-trash"/>
                <p:commandButton type="push" title="Print" image="ui-icon-print"/>
            </p:toolbarGroup>

        </p:toolbar>
    </cc:implementation>
</html>
For completeness sake, here is the header composite component code:

Code: Select all

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:p="http://primefaces.org/ui">

    <!-- INTERFACE -->
    <cc:interface>
    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>
        <p:outputPanel styleClass="header" >
            <p:outputPanel styleClass="headerCenter" >
                <h:panelGrid columns="3" styleClass="headerUserInfo" >
                    <h:outputText value="" />
                    <h:outputText value="Company: Sunny Beaches" />
                    <h:outputText value="User: Ichabod Grabarkowitz" />
                </h:panelGrid>
            </p:outputPanel>
            <p:outputPanel styleClass="headerLeft" >
                <p:outputPanel styleClass="headerLogo" >
                    <h:outputText value="Logo goes here" />
                </p:outputPanel>
            </p:outputPanel>
            <p:outputPanel styleClass="headerRight" >
                <h:panelGrid columns="1" style="margin-top: 10px;" >
                    <p:outputPanel  >
                        <h:commandLink value="Logout" style="padding-left: 10px; padding-right: 10px; color: #000000" />
                        <h:commandLink value="About" style="padding-left: 10px; padding-right: 10px; color: #000000" />
                        <h:commandLink value="Help" style="padding-left: 10px; padding-right: 10px; color: #000000" />
                    </p:outputPanel>
                </h:panelGrid>
            </p:outputPanel>
        </p:outputPanel>
    </cc:implementation>
</html>
And the page code:

Code: Select all

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:comp="http://java.sun.com/jsf/composite/ezcomp"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

    <body>

        <ui:composition template="./LoginTemplate.xhtml">
            <!-- ui:define name="top">
                top
            </ui:define -->

            <!-- ui:define name="left">
                <h:form>
                    <comp:menu id="menuComp" />
                </h:form>
            </ui:define -->

            <ui:define name="content">
                <h:form >
                    <comp:message id="messageComp" />
                    <comp:loginPanel id="loginComp" />
                </h:form >
            </ui:define>
        </ui:composition>

    </body>
</html>
Using PrimeFaces 3.4, Mojarra 2.1.6, Glassfish 3.1.2, NetBerans 7.2, Hibernate 3.2.5 (sometimes)
Windows 7.

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

18 Nov 2011, 01:43

Click URL below, and read the responses/answers, especially from user, BalusC, (he specializes in JSF, and answers a lot of JSF questions).

http://stackoverflow.com/questions/2055 ... on-in-java
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

18 Nov 2011, 01:50

One more for you.

http://stackoverflow.com/questions/7433 ... -committed

Answer from this page copy/pasted below:
[SOLVED]

It took days to diagnose this problem, but finally I am able to solve this problem.

It was actually @ViewScoped and it has a managed property DAO object which was not serialized. So after view is rendered, facelets also produce this exception, but JSF view already rendered and that's why this exception showed.

Solution: Make all objects serialized in @ViewScoped bean, and mark "transient" who are not serialized like in my case it was DAO object in JSF @ViewScoped.
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

burferd
Posts: 234
Joined: 01 May 2010, 16:15

18 Nov 2011, 22:16

I can see that the error happens wen attemptiing to render the HomePage.xhtml, but I still do not understand what is causing it.

I have no backing bean code, I am just attempting to display the combination of components on the page.

This leads me to believe that I have some combination of components or invalid syntax that is causing the problem, and that is what has me baffled.

I note that if I display the header and the menuToolBar composite components together, I am OK until I add a second <p:menuButton> component to the menuToolBar component.

If I can't even display the page layout, without any server side references, then it seems that either some of the components do not play well with each other or else I have some syntax issues.

I can't see any obvious syntax problems, and I am not versed enough in what goes ob behind the scenes to understand why the page can't render.
Using PrimeFaces 3.4, Mojarra 2.1.6, Glassfish 3.1.2, NetBerans 7.2, Hibernate 3.2.5 (sometimes)
Windows 7.

burferd
Posts: 234
Joined: 01 May 2010, 16:15

19 Nov 2011, 00:46

I was able to avoid this error by removing the <p:toolBarGroup> containing the <p:commandButtons>.

I was also able to avoid this error by adding <f:view beforePhase=... to call an initialization method in my backing session bean. When I do this, I can add the <p:toolBarGroup> containing the <p:commandButtons> back in.

Still not sure why I go this error when I just tried to display the raw page with no data.
Using PrimeFaces 3.4, Mojarra 2.1.6, Glassfish 3.1.2, NetBerans 7.2, Hibernate 3.2.5 (sometimes)
Windows 7.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 23 guests