Is it possible? FacesContext.getCurrentInstance()
returns null.
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.