I have bean that i recently converted over from being a managed-bean to being a spring-bean.
Everything was ok until at some point the following method is called:
Exception e = (Exception) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get(
AbstractProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY);
At this point things blow up because FacesContext.getCurrentInstance() returns null.
is it possible to inject the faces context into my bean?
Not sure, but in this particular case it’s not needed. The
ExternalContext#getSessionMap()is basically a facade to the attributes ofHttpSession. To the point, you just need to grab theHttpServletRequestin your Spring bean somehow and then get theHttpSessionfrom it byHttpServletRequest#getSession(). Then you can access the session attributes byHttpSession#getAttribute().I don’t do Spring, but Google learns me that you could obtain it as follows:
Once done that, you can just do: