[jboss-jira] [JBoss JIRA] Created: (JBAS-8387) support injection for a servlet that is registered programmatically
Marcel Kolsteren (JIRA)
jira-events at lists.jboss.org
Fri Sep 3 12:29:52 EDT 2010
support injection for a servlet that is registered programmatically
-------------------------------------------------------------------
Key: JBAS-8387
URL: https://jira.jboss.org/browse/JBAS-8387
Project: JBoss Application Server
Issue Type: Feature Request
Security Level: Public (Everyone can see)
Components: Weld/CDI
Affects Versions: 6.0.0.M4
Reporter: Marcel Kolsteren
Assignee: Marius Bogoevici
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
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list