Everything works fine in glassfish and Wildfly. In tomcat bean injection works fine in servlet, and ServletContextListener. But in WebSocket endpoint, no way.
-
I add of course a maven dependency of weld
<dependency> <groupId>org.jboss.weld.servlet</groupId> <artifactId>weld-servlet-core</artifactId> <version>3.0.0.Alpha11</version> </dependency>
-
In context.xml I add the resource BeanManager
<Resource auth="Container" factory="org.jboss.weld.resources.ManagerObjectFactory" name="BeanManager" type="javax.enterprise.inject.spi.BeanManager"/>
-
And in web.xml, I add the listener and resource-ref
<listener> <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class> </listener> <resource-env-ref> <resource-env-ref-name>BeanManager</resource-env-ref-name> <resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type> </resource-env-ref>
|