Openfaces datatable issue: throwing exception (com.sun.​faces.face​lets.compi​ler.UIInst​ructions)

811 Views Asked by At

I am using using myfaces 2.1.10 faces engine along with open faces 3.1 (openfaces-3.1.EA1.1198.jar) in my web application running on weblogic server 12c. The web application is using facelets template to load header/content/footer pages(.xhtml).

In the content page I have placed a input text field along with a search button along with openfaces's datatable. When I enter text to search and then by clicking the search button, system returns some data and populates the openfaces data table component that I have placed in the same page but when I am trying to search again I am getting exception as pasted below. I believe this issue is caused by openfaces data table because when I replaced with jsf datatable, everything works fine. I have to use openfaces datatable as it suits my requirement with pagination, filtering etc.

For Clarity, I am pasting code snippets from web.xml and the content page(roleMaintenance.xhtml).

Thanks in advance for all your help and support.

web.xml:

<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.xhtml</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.FULL_STATE_SAVING_VIEW_IDS</param-name>
        <param-value>/pages/roleMaintenance.xhtml</param-value>
    </context-param>
    <listener>
        <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

roleMaintenance.xhtml:

    <!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:t="http://myfaces.apache.org/tomahawk"
xmlns:o="http://openfaces.org/">
<ui:composition
template="/resources/common/templates/rsaMasterTemplate.xhtml">
<ui:define name="content">
<f:view>
<table width="100%">
<tr>
<td>
<table width="50%"><tr>
<td><h:outputLabel styleClass="fieldLabelText"
value="#{message['application.common.label.searchBy']}"/>
</td>

<td><h:selectOneMenu class="entryfieldText"
value="#{securityRoleMaintenanceManagedBean.selectedSearchCriteria}">
<f:selectItem itemValue="Role" itemLabel="Role" />
<f:selectItem itemValue="Desc" itemLabel="Desc" />
</h:selectOneMenu></td>

<td><h:inputText size="30" class="entryfieldText"
value="#{securityRoleMaintenanceManagedBean.searchValue}">
</h:inputText></td>

<td><h:commandLink
action="#{securityRoleMaintenanceManagedBean.search}"
styleClass="buttonOrange">
<span><h:outputText
value="#{message['application.common.button.search']}" /></span>
</h:commandLink></td>
<td class="cellSpacer"></td>

<td colspan="5"><o:dataTable id="dTbl_RM"
value="#{securityRoleMaintenanceManagedBean.roleDtos}"
var="role" rowIndexVar="rowIndex"
horizontalGridLines="1px solid gray"
verticalGridLines="1px solid gray">
<o:scrolling autoScrollbars="true" />
<o:row condition="#{rowIndex%2 == 0}"
styleClass="standardTable_Row2" />
<o:column>
<f:facet name="header">
<h:outputText
value="#{message['application.security.roleadmin.label.role']}"
styleClass="scrollerTable headerText" />
</f:facet>
<h:outputText align="center" value="#{role.role}"
styleClass="scrollerTable cellText" />
</o:column>
<o:column>
<f:facet name="header">
<h:outputText
value="#{message['application.security.roleadmin.label.description']}"
styleClass="scrollerTable headerText" />
</f:facet>
<h:outputText align="center" value="#{role.description}"
styleClass="scrollerTable cellText" />
</o:column>
<o:column>
<f:facet name="header">
<h:outputText
value="#{message['application.common.label.actions']}"
styleClass="scrollerTable headerText" />
</f:facet>

<table>
<tr>
<td><h:commandLink
actionListener="#{securityRoleMaintenanceManagedBean.displayEditRole}"
value="#{message['application.common.link.edit']}"
styleClass="scrollerTable cellText">
<f:attribute name="selection" value="#{role}" />
</h:commandLink></td>

<td class="cellSpacer"></td>
<td class="cellSpacer"></td>
<td>
<div>
<h:commandLink
onclick="if (! confirm('Really delete this?') ) { return false;}; return true; "
actionListener="#{securityRoleMaintenanceManagedBean.deleteRole}"
value="#{message['application.common.link.delete']}"
styleClass="scrollerTable cellText">
<f:attribute name="selection" value="#{role}" />
</h:commandLink>

</div>
</td>
</tr>
</table>
</o:column>
</o:dataTable></td>
</tr>
</table>
</h:panelGroup></td>
</tr>
</table>
</td>
</tr>

</table>
</f:view>
</ui:define>
</ui:composition>
</html>

error print stack trace

   java.lang.InstantiationException: com.sun.faces.facelets.compiler.UIInstructions
at java.lang.Class.newInstance0(Class.java:340)
at java.lang.Class.newInstance(Class.java:308)
at   com.sun.faces.application.StateManagerImpl.newInstance(StateManagerImpl.java:296)
at com.sun.faces.application.StateManagerImpl.restoreTree(StateManagerImpl.java:326)
at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:203)
at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:453)
at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:148)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:192)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:242)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:216)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:132)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:338)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:74)
at org.openfaces.util.ResourceFilter.doFilter(ResourceFilter.java:41)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:74)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:74)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3288)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3254)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2163)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2089)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2074)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1513)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
1

There are 1 best solutions below

2
On

This bug is caused by a disabled partial state saving. If you remove the following entries from web.xml

<context-param>
    <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
    <param-value>false</param-value>
</context-param>
<context-param>
    <param-name>javax.faces.FULL_STATE_SAVING_VIEW_IDS</param-name>
    <param-value>/pages/roleMaintenance.xhtml</param-value>
</context-param>

then it should theoretically work.

This is essentially a bug in OpenFaces. It is somehow forcing a non-transient state while it has to be transient. RichFaces 4.2.0 has previously had such a bug which is in detail explained in this JBoss community thread. See also the below relevant extract:

So, during encoding - all children of UIOutputPanel are set as non-transient (even nodes of UIInstructions type).

Workaround:

public class UIOutputPanelWorkaround extends UIOutputPanel
{
  public boolean isKeepTransient() {
    Boolean value = (Boolean) getStateHelper().eval(Properties.keepTransient, false);
    return value;
  }
}

and in faces-config:

  <component>
    <component-type>org.richfaces.OutputPanel</component-type>
    <component-class>com.example.UIOutputPanelWorkaround</component-class>
  </component>

It seems that this bug is already reported to OpenFaces as issue 206, but there doesn't seem to be any progress. You might want to comment/vote it in order to push it. Or just turn back on the partial state saving. Whatever problem you thought to solve with disabling the partial state saving may need to be solved in a different way.