Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-8387

support injection for a servlet that is registered programmatically

    XMLWordPrintable

Details

    • Feature Request
    • Resolution: Unresolved
    • Major
    • No Release
    • 6.0.0.M4
    • Weld/CDI
    • None
    • 0
    • 0% 0%

    Description

      Injection of a CDI Managed Bean into a servlet works for servlets that are registered using web.xml, but fails for servlets that are registered using the addServlet() method of the servlet context. Supporting injection in both cases would be more consistent and more convenient for developers.

      In order to demonstrate this issue, I created an Arquillian test for a managed JBoss M4 application server. The test deploys a war-file that contains two servlets. Both servlets refer to the same servlet class. The servlet class is very simple: it has a field into which a request scoped bean is injected, and it reports to the client whether or not this field contains a null value. The first servlet is defined in the web.xml file, the second servlet is registered programmatically by calling ServletContext.addServlet. The test cases show that the first servlet works as expected. However, the second servlet detects a null value in the field that should contain an injected instance of the request scoped bean. Steps for reproduction:

      unpack the attached zip file
      export JAVA_HOME = <home of your JDK>
      export JBOSS_HOME = <root directory of your JBoss 6 M4 server>
      mvn test

      Attachments

        Activity

          People

            marius.bogoevici Marius Bogoevici (Inactive)
            marcelkolsteren_jira Marcel Kolsteren (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: