I know Romain's done some work in this area before. Per the spec, its not required to work the way you have it defined. JAX-RS injection via @Context is only mandated to work in JAX-RS managed components.
Try to use @Inject instead of @Context, that may be what was implemented in TomEE. That is mandated in EE7 (but not in EE6). John On Sun, May 8, 2016 at 7:36 AM Kirys <ki...@neoteroi.org> wrote: > I'm am making some experiments > and I've written this cdi called from within a jsf page > but I get a nullpointer exception is that a valid setup or is not legit > to get HttpServletRequest from within a request scoped cdi? > > Thank You > > Details follow: > > Apache Tomcat (TomEE)/7.0.68 (1.7.4) (plumee) > > CDI code extract > > @Named > @RequestScoped > public class UserProfileManager implements Serializable { > > @Context > private ServletContext context; > > @Context > private HttpServletRequest request; > @Context > private HttpServletResponse response; > > public LoggedUser getUser() { > Enumeration<String> names= request.getAttributeNames(); //null > pointer exception here -> request is not null > /* other not relevant code */ > > } > > > } >