1 Reply Latest reply on Jan 31, 2013 3:24 AM by Martin Kouba

    Portable way to associate existing request with request context?

    arjan tijms Novice

      I'm trying to use CDI in a JASPIC SAM for the Servlet Container profile. The SAM is called with an HttpServletRequest and HttpServletResponse, and an HttpSession can be easily obtained from them.

       

      Unfortunately, despite the availability of these objects, not all servers have the CDI request and session scope activated at this point. In JBoss AS it's active at this point, and in GlassFish more or less as well (it barks a little, but obtaining scoped beans from the bean manager works). However in WebLogic the scope clearly isn't active and the infamous "WELD-001303 No active contexts for scope type javax.enterprise.context.RequestScoped" is thrown whenever I'm trying to access a request scoped bean that is obtained from the bean manager. When I lookup a session scoped bean a similar exception is already thrown at the point of looking up the bean.

       

      Weld seems to have some API available to manually activate this scope (http://docs.jboss.org/weld/reference/latest/en-US/html/contexts.html), but can this be done in a portable way?