I have a filter: UserSessionFilter.java
, that I use to handle user sessions and a ApplicationScoped
bean: Config.java
that primarily gives me access to a DAO factory
.
Config.java
@ManagedBean (eager = true)
@ApplicationScoped
public class Config implements Serializable {...
The filter calls a method in Config
to get a DAOFactory
object:
Filter method
@Override
public void init(FilterConfig filterConfig) {
daoFactory = Config.getInstance().getDAOFactory();
}
Config method
public static Config getInstance() {
FacesContext facesContext = FacesContext.getCurrentInstance();
return (Config) facesContext.getApplication().evaluateExpressionGet(
facesContext, "#{config}", Config.class);
}
My problem is that the facesContext
gets set to null
. This problem started occurring after switch from Mojarra
to MyFaces
, although it seems weird that that would cause it.