tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John D. Ament" <johndam...@apache.org>
Subject Re: Is this legit? @RequestScoped vs HttpServletRequest
Date Sun, 08 May 2016 16:09:54 GMT
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 <kirys@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 */
>
>      }
>
>
> }
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message