What might be the reason for JSF/MyFaces to lose its FacesContext?

1.1k views Asked by At

I have a webapplication based on JSF(2.1.17) myfaces /PrimeFaces + Omnifaces on WAS 8.0.0.9

Most of the time everything works ok, but occasionally I get the following exception:

java.lang.NullPointerException
        at org.apache.myfaces.shared.context.flash.FlashImpl.isKeepMessages(FlashImpl.java:388)
        at org.apache.myfaces.shared.context.flash.FlashImpl._saveMessages(FlashImpl.java:668)
        at org.apache.myfaces.shared.context.flash.FlashImpl.doPostPhaseActions(FlashImpl.java:269)
        at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:254)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:199)
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1230)
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:779)
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
        at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
        at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136)
        at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:97)
        at org.omnifaces.filter.FacesExceptionFilter.doFilter(FacesExceptionFilter.java:56)
        at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:77)
        at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
        at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)

// ... more filters ...

When looking at FlashImpl line388 if find:

@Override
public boolean isKeepMessages()
{
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = facesContext.getExternalContext(); //<-- line 388
    Map<String, Object> requestMap = externalContext.getRequestMap();
    Boolean keepMessages = (Boolean) requestMap.get(FLASH_KEEP_MESSAGES);

    return (keepMessages == null ? Boolean.FALSE : keepMessages);
}

So it looks like there is no FacesContext. Although (again from looking at the code) it should get created in FacesServlet.service further up the call stack.

One of the filters we have registered logs time used in the different phases of the JSF lifecycle, and it complains that the phase RENDER_RESPONSE is started, although it is already running.

Logging is also suggesting that in the current request the requested page could not be found and therefor the apropriate error page is requested.

All this might happen during an Ajax request but I am not sure.

Any ideas what might be causing this problem?

I found this bugreport but couldn't find a reference to getRequestDispatcher so it doesn't seem to apply.

I also found this question: Null pointer exception in FlashImpl.java in IBM JSF which actually might be a duplicate but since I have more (possibly relevant) information which might or might not apply to the other question I thought it better to create a new one.

0

There are 0 answers