-
1. Re: Servlets not receiving injections
gavin.king Jun 4, 2009 5:26 PM (in response to meetoblivion)AFAIK, injection into servlets is not yet supported in the RI.
-
2. Re: Servlets not receiving injections
meetoblivion Jun 4, 2009 5:35 PM (in response to meetoblivion) -
3. Re: Servlets not receiving injections
gavin.king Jun 4, 2009 7:59 PM (in response to meetoblivion)Well, I'm wrong then. Happens :-)
-
4. Re: Servlets not receiving injections
meetoblivion Jun 4, 2009 8:40 PM (in response to meetoblivion)Not saying you're wrong, I'm more inclined to believe the docs are wrong. I added direct manager lookup via JNDI and it's there, so I'm inclined to think that someone was going to add in servlet injection, but the version of WebBeans on JBAS5.1 isn't working. So docs are maybe out of sync w/ 5.1?
-
5. Re: Servlets not receiving injections
viviansteller.vivian.steller.uni-ulm.de Jun 5, 2009 2:51 AM (in response to meetoblivion)I think injection into servlets currently only works in Tomcat 6 (with the appropriate Listener configured in your context.xml file, see the docs for details).
Though, it's not implemented for any version of JBoss AS. See WBINT-5
-
6. Re: Servlets not receiving injections
alin.heyoulin.qq.com Jun 5, 2009 6:36 AM (in response to meetoblivion)you can see org.jboss.webbeans.environment.tomcat.WebBeansAnnotationProcessor public void processAnnotations(Object instance) throws IllegalAccessException, InvocationTargetException, NamingException { manager.injectNonContextualInstance(instance); } and org.jboss.webbeans.environment.servlet.Listener if (tomcat) { // Try pushing a Tomcat AnnotationProcessor into the servlet context try { Class<?> clazz = Reflections.loadClass(WebBeansAnnotationProcessor.class.getName(), Object.class); Object annotationProcessor = clazz.getConstructor(WebBeansManager.class).newInstance(manager); sce.getServletContext().setAttribute(WebBeansAnnotationProcessor.class.getName(), annotationProcessor); } catch (Exception e) { log.error("Unable to create Tomcat AnnotationProcessor. JSR-299 injection will not be available in Servlets, Filters etc.", e); } } and org.jboss.webbeans.environment.tomcat.WebBeansLifecycleListener private AnnotationProcessor getProcessor() { if (processor == null) { Object o = servletContext.getAttribute("org.jboss.webbeans.environment.tomcat.WebBeansAnnotationProcessor"); if (o instanceof AnnotationProcessor) { processor = (AnnotationProcessor) o; } else { return DUMMY_PROCESSOR; } } return processor; } so injection into servlets only works in tomacat,and you must add <Listener className="org.jboss.webbeans.environment.tomcat.WebBeansLifecycleListener"/> to context.xml
-
7. Re: Servlets not receiving injections
pmuir Jun 6, 2009 11:48 PM (in response to meetoblivion)
Vivian Steller wrote on Jun 05, 2009 02:51:
I think injection into servlets currently only works in Tomcat 6 (with the appropriate Listener configured in your context.xml file, see the docs for details).
Though, it's not implemented for any version of JBoss AS. See WBINT-5100% correct, JBoss 5 is still using some JBoss 4 legacy code in this area, and so we struggled to find a good way to make it work. There will probably have to be another JBoss release to have it work correctly :-(