Hi,
I'm getting an error when I call authenticate() within a preRenderView
listener in a managed bean. It looks like a bug in Mojarra, but I just
wanted to ask here before creating an Issue in Jira.
Here is my code:
public void preRender(ComponentSystemEvent event) {
HttpServletRequest request =
(HttpServletRequest)FacesContext.getCurrentInstance().getExternalContex
t().getRequest();
HttpServletResponse response =
(HttpServletResponse)FacesContext.getCurrentInstance().getExternalConte
xt().getResponse();
try {
if (!request.authenticate(response)) {
// can't call responseComplete() here, because
FacesContext.getCurrentInstance() == null.
// FacesContext.getCurrentInstance().responseComplete();
}
} catch (Exception e) { // may throw ServletException or
IOException
System.out.println("EXCEPTION calling authenticate");
e.printStackTrace();
}
When the method is called I get this error:
javax.enterprise.resource.webcontainer.jsf.context|_ThreadID=23;_Thread
Name=Thread-3;|Exception when handling error trying to reset the
response.
java.lang.NullPointerException
at
com.sun.faces.facelets.tag.jsf.core.DeclarativeSystemEventListener.proc
essEvent(EventHandler.java:126)
I tried calling responseComplete() to fix the error, but after the call
to authenticate(), the FacesContext.getCurrentInstance() returns null
Is this a bug in Mojarra, or am I calling authenticate incorrectly?
Thanks,
Ellen