JSF Myfaces NullPointerException: serialFactory

ぃ、小莉子 提交于 2019-12-11 05:45:03

问题


Im a bit at my wits end here. Im getting the following in my logs when I try to render a JSF page:

java.lang.NullPointerException: serialFactory
at org.apache.myfaces.shared_impl.util.StateUtils.getAsByteArray(StateUtils.java:182)
at org.apache.myfaces.shared_impl.util.StateUtils.construct(StateUtils.java:149)
at org.apache.myfaces.renderkit.html.HtmlResponseStateManager.writeViewStateField(HtmlResponseStateManager.java:104)
at org.apache.myfaces.renderkit.html.HtmlResponseStateManager.writeState(HtmlResponseStateManager.java:94)
at javax.faces.render.ResponseStateManager.writeState(ResponseStateManager.java:67)
at org.ajax4jsf.application.AjaxStateManager.writeState(AjaxStateManager.java:294)
at org.ajax4jsf.application.AjaxStateManager.writeState(AjaxStateManager.java:256)
at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:620)
at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:140)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:155)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:301)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at za.co.fnbconnect.portal.util.SessionTimeoutFilter.doFilter(SessionTimeoutFilter.java:94)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at za.co.fnbconnect.portal.util.StatsFilter.doFilter(StatsFilter.java:90)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
at java.lang.Thread.run(Unknown Source)

This is my web.xml

<?xml version="1.0"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <!-- Use Documents Saved as *.xhtml -->
    <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.xhtml</param-value>
    </context-param>
    <!-- Special Debug Output for Development -->
    <context-param>
        <param-name>facelets.DEVELOPMENT</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.ERROR_HANDLING</param-name>
        <param-value>false</param-value>
    </context-param>
    <!-- Optional JSF-RI Parameters to Help Debug -->
    <context-param>
        <param-name>com.sun.faces.validateXml</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>com.sun.faces.verifyObjects</param-name>
        <param-value>true</param-value>
    </context-param>
    <!-- context-param>
        <param-name>javax.faces.CONFIG_FILES</param-name>
        <param-value>
        /WEB-INF/faces-config.xml
        </param-value>
        </context-param-->
    <context-param>
        <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
        <param-value>com.sun.facelets.FaceletViewHandler</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>server</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.CONFIG_FILES</param-name>
        <param-value>
            /WEB-INF/faces-config-connections.xml,
            /WEB-INF/faces-config-general.xml,
            /WEB-INF/faces-config-ims.xml,
            /WEB-INF/faces-config-maintenance.xml,
            /WEB-INF/faces-config-menu.xml,
            /WEB-INF/faces-config-profile.xml,
            /WEB-INF/faces-config-registration-activation.xml,
            /WEB-INF/faces-config-registration.xml,
            /WEB-INF/faces-config-solutions.xml,
            /WEB-INF/faces-config-topup.xml,            
            /WEB-INF/faces-config-transfer.xml
        </param-value>
    </context-param>
    <context-param> 
        <description>Used for  addition Im. Only relevant for client side 
            state saving. See MyFaces wiki/web site documentation for instructions 
            on how to configure an application for diffenent encryption strengths. 
        </description> 
        <param-name>org.apache.myfaces.SECRET</param-name> 
        <param-value>NzY1NDMyMTA=</param-value> 
    </context-param> 
    <context-param>
        <param-name>org.apache.myfaces.SERIAL_FACTORY</param-name>
        <param-value>org.apache.myfaces.JbossSerialFactory</param-value>
    </context-param>
    <filter>
        <filter-name>SessionTimeoutFilter</filter-name>
        <filter-class>
            za.co.fnbconnect.portal.util.SessionTimeoutFilter
        </filter-class>
    </filter>
    <filter>
        <filter-name>StatsFilter</filter-name>
        <filter-class>
            za.co.fnbconnect.portal.util.StatsFilter
        </filter-class>
    </filter>
    <filter-mapping>
        <filter-name>StatsFilter</filter-name>
        <url-pattern>*.faces</url-pattern>
    </filter-mapping>
    <filter>
        <display-name>RichFaces Filter</display-name>
        <filter-name>richfaces</filter-name>
        <filter-class>org.ajax4jsf.Filter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>SessionTimeoutFilter</filter-name>
        <url-pattern>*.faces</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>richfaces</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
    </filter-mapping>
    <!-- tomahawk extension filters -->
    <filter>
        <filter-name>MyFacesExtensionsFilter</filter-name>
        <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
        <init-param>
            <param-name>uploadMaxFileSize</param-name>
            <param-value>20m</param-value>
        </init-param>
    </filter>

    <!-- extension mapping for adding <script/>, <link/>, and other resource tags to JSF-pages  -->
    <filter-mapping>
        <filter-name>MyFacesExtensionsFilter</filter-name>
        <!-- servlet-name must match the name of your javax.faces.webapp.FacesServlet entry -->
        <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>

    <!-- extension mapping for serving page-independent resources (javascript, stylesheets, images, etc.)  -->
    <filter-mapping>
        <filter-name>MyFacesExtensionsFilter</filter-name>
        <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
    </filter-mapping>   
    <!-- end -->    
    <listener>
        <listener-class>
            za.co.fnbconnect.portal.util.FNBConnectSessionListener
        </listener-class>
    </listener>
    <!-- Listener, that does all the startup work (configuration, init). -->
    <listener>
        <listener-class>
            org.apache.myfaces.webapp.StartupServletContextListener
        </listener-class>
    </listener>
    <servlet>
        <servlet-name>Log4jInitialiser</servlet-name>
        <servlet-class>za.co.fnbconnect.log4j.Log4jInitializer</servlet-class>
        <!--  DEV -->
        <init-param>
            <param-name>DEV-hosts</param-name>
            <param-value>192.168.18.14</param-value>
        </init-param>
        <init-param>
            <param-name>DEV-log4j-init-file</param-name>
            <param-value>/opt/PropertiesManager/tomcat-log4j-DEV.xml</param-value>
        </init-param>

        <!--  INT -->
        <init-param>
            <param-name>INT-hosts</param-name>
            <param-value>192.168.18.73</param-value>
        </init-param>
        <init-param>
            <param-name>INT-log4j-init-file</param-name>
            <param-value>/opt/PropertiesManager/tomcat-log4j-INT.xml</param-value>
        </init-param>

        <!--  PREPROD -->
        <init-param>
            <param-name>PREPROD-hosts</param-name>
            <param-value>192.168.18.139</param-value>
        </init-param>
        <init-param>
            <param-name>PREPROD-log4j-init-file</param-name>
            <param-value>/opt/PropertiesManager/tomcat-log4j-PREPROD.xml</param-value>
        </init-param>

        <!--  LOAD -->
        <init-param>
            <param-name>LOAD-hosts</param-name>
            <param-value>192.168.44.6,192.168.44.13</param-value>
        </init-param>
        <init-param>
            <param-name>LOAD-log4j-init-file</param-name>
            <param-value>/opt/PropertiesManager/tomcat-log4j-LOAD.xml</param-value>
        </init-param>

        <!--  PROD -->
        <init-param>
            <param-name>PROD-hosts</param-name>
            <param-value>192.168.34.6,192.168.34.135</param-value>
        </init-param>
        <init-param>
            <param-name>PROD-log4j-init-file</param-name>
            <param-value>/opt/PropertiesManager/tomcat-log4j-PROD.xml</param-value>
        </init-param>


        <!--  Default when running on the PC -->
        <init-param>
            <param-name>DEFAULT-log4j-init-file</param-name>
            <param-value>C:/FNBConnect/PropertiesManager/FE/tomcat-log4j-PC.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.faces</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>10</session-timeout>
    </session-config>
    <!-- Welcome files -->
    <error-page>
        <error-code>401</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>402</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>403</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>404</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>405</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>406</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>407</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>408</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>409</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>410</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>411</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>412</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>413</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>414</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>415</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>416</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>417</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>418</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>422</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>423</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>424</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>425</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>426</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>449</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>500</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>501</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>502</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>503</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>504</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>505</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>506</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>507</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>509</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>
    <error-page>
        <error-code>510</error-code>
        <location>/GeneralError.jsp</location>
    </error-page>   
    <login-config>
        <auth-method>BASIC</auth-method>
    </login-config>
</web-app>

Ive looked at the source and it seems to want to get the org.apache.myfaces.SERIAL_FACTORY from the context, whitch is not there for some reason. Any-one has any ideas?


回答1:


Just a guess (I have not tried this out), but it does appear to be a similar stack trace, as well as a code fix of exporting SERIAL_FACTORY as an Attribute:

http://wiki.apache.org/myfaces/PortletSerialFactoryWorkaround

Here is the exception they specify:

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)

And, the fix they recommend: "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()); 
}


来源:https://stackoverflow.com/questions/1492863/jsf-myfaces-nullpointerexception-serialfactory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!