ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
beanManager = CDIUtils.getBeanManager(externalContext);
Object context = externalContext.getContext();
if (context instanceof ServletContext)
{
ApplicationContextBean appBean = CDIUtils.lookup(beanManager,
ApplicationContextBean.class);
appBean.setServletContext((ServletContext) context);
}
}