At what point are you trying to get the ServletContext :
At the time of the request, HttpServletRequest : ServletContexts.instance().getRequest().getServletContext() .
At the time of the JSF request: (ServletContext)FacesContext.getCurrentInstance().getExternalContext() .
At application startup: ServletLifecycle.getServletContext() .
source share