java.lang.NullPointerException at com.sun.faces.context.flash.ELFlash.loggingGetPhaseMapForReading [duplicate]

最后都变了- 提交于 2019-12-08 18:41:43

问题


I am running my application in apache-tomcat-7.0.16 using JSF-2.1.2. After adding navigation rules in faces-config.xml, I am getting the NullPointerException. This bug was filed in JSF forum. Is there any compatible version between JSF and the tomcat app server or any solution for this? Error stack trace is given below:

java.lang.NullPointerException
    at com.sun.faces.context.flash.ELFlash.loggingGetPhaseMapForReading(ELFlash.java:793)
    at com.sun.faces.context.flash.ELFlash.getPhaseMapForReading(ELFlash.java:826)
    at com.sun.faces.context.flash.ELFlash.isEmpty(ELFlash.java:484)
    at com.sun.faces.facelets.util.DevTools.writeVariables(DevTools.java:325)
    at com.sun.faces.facelets.util.DevTools.writeVariables(DevTools.java:215)
    at com.sun.faces.facelets.util.DevTools.debugHtml(DevTools.java:130)
    at com.sun.faces.renderkit.RenderKitUtils.renderHtmlErrorPage(RenderKitUtils.java:1159)
    at com.sun.faces.context.ExceptionHandlerImpl.throwIt(ExceptionHandlerImpl.java:269)
    at com.sun.faces.context.ExceptionHandlerImpl.handle(ExceptionHandlerImpl.java:141)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
    at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:546)
    at com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:364)
    at com.sun.faces.application.view.JspViewHandlingStrategy.buildView(JspViewHandlingStrategy.java:154)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:100)
    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.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    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:127)
    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:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:662)

回答1:


Same issue with Tomcat 7.0.26 and and JSF 2.1.7. Works with JSF 2.0.9

Initially had just configured

    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.1.7</version>
    </dependency>
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>2.1.7</version>
    </dependency>

But got java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config

It was only after attempting to add a dependency on jstl that I got the NullPointerException. After rolling back to JSF 2.0.9, I also removed the dependency on jstl.




回答2:


Recently, I had a similar problem with the same error stack trace. <welcome-file-list> entry was like this when I got that error:

<welcome-file-list>
        <welcome-file>index.xhtml</welcome-file>
</welcome-file-list>

However, the error disappeared when I changed the entry to (denote the leading faces):

<welcome-file-list>
        <welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>



回答3:


I was facing same issue. I was able to solve it by modifying faces-config.xml as below

<faces-config
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
    version="2.0">


</faces-config>


来源:https://stackoverflow.com/questions/7008507/java-lang-nullpointerexception-at-com-sun-faces-context-flash-elflash-loggingget

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