4 Replies Latest reply on Sep 4, 2010 2:19 AM by jaikiran pai

    injection into a programmatically registered servlet

    Marcel Kolsteren Apprentice

      Injection doesn't seem to take place in a servlet that is registered programmatically.


      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 correctly. However, the second servlet detects a null value in the field that should contain an injected instance of the request scoped bean.


      This seems to be a bug. Or did I miss something in the CDI spec?


      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