Question

Is it possible? FacesContext.getCurrentInstance() returns null.

Was it helpful?

Solution

A regular servlet isn't initialized/called during a JSF request, so there's no means of a FacesContext in a servlet. Only when the request URL matches the FacesServlet, then there's a FacesContext. You should register the PhaseListener in faces-config.xml or in a JSF managed bean instead. Consider doing it in the (post)constructor of an application scoped managed bean.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top