Uploaded image for project: 'Tools (JBoss Tools)'
  1. Tools (JBoss Tools)
  2. JBIDE-26029

Incorrect warning for @Inject ServletContext

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 4.6.0.AM3
    • 4.5.3.Final
    • cdi
    • None

      If you inject ServletContext into a CDI bean, it gets flagged with this warning:

      No bean is eligible for injection to the injection point [JSR-346 ยง5.2.2]

      This warning appears to be correct for CDI 1.0, but not for later versions. From CDI 2.0 spec section 18.8 (also CDI 1.1/1.2 section 3.8):

      A servlet container must provide the following built-in beans, all of which have qualifier @Default:

      • a bean with bean type javax.servlet.http.HttpServletRequest, allowing injection of a reference to the HttpServletRequest
      • a bean with bean type javax.servlet.http.HttpSession, allowing injection of a reference to the HttpSession,
      • a bean with bean type javax.servlet.ServletContext, allowing injection of a reference to the ServletContext,

            jmaury@redhat.com Jeff MAURY
            rdicroce Richard DiCroce (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: