MyFaces 1.1.4 has a bug that can cause the following error in a portlet environment:

java.lang.NullPointerException: serialFactory
        at org.apache.myfaces.shared_impl.util.StateUtils.getAsByteArray(StateUtils.java:174)
        at org.apache.myfaces.shared_impl.util.StateUtils.construct(StateUtils.java:150)
        at org.apache.myfaces.renderkit.html.HtmlResponseStateManager.writeState(HtmlResponseStateMa
nager.java:73)
        at org.apache.myfaces.application.jsp.JspStateManagerImpl.writeState(JspStateManagerImpl.jav
a:430)

To work around this problem, extend MyFacesGenericPortlet and override the init() method as follows:

public void init() throws PortletException, UnavailableException
{
   super.init();
   getPortletContext().setAttribute("org.apache.myfaces.SERIAL_FACTORY", new org.apache.myfaces.shared_impl.util.serial.DefaultSerialFactory()); 
}

If you want to use your own serial factory as per Performance, you can just replace DefaultSerialFactory with the fully-qualified class name of your own implementation.

  • No labels