@EJB injection works for Servlet, fails for WebServiceEndpoint
The following situation is a WAR existing inside an EAR, whereby the EAR contains a single @Stateless session bean deployed in a JAR. Access to the session bean using dependency injection already works within the EAR from a seperate JSF application. The issue is in getting dependency injection to work for the WebService WAR.
Here are snippets from my web.xml file:
I have attached additional sun-*.xml files to show how the second servlet entry maps to a web service endpoint class. These entries were based on SUNs J2EE 5 sample code.
In the first entry, @EJB injection annotation for a Local Session Bean works inside the servlet-class.
The injection fails for the second entry.
Here is a snippet from my sun-jaxws.xml file:
Here you can see that the second servlet entry in my web.xml maps to the class com.roamdata.gateway.webservice.RoamGatewayImpl. Again, these were taken from SUN provided sample code.
However, @EJB injection does not work in this class. I get a NullPointerException. Here is how the dependency injection is defined:
public GatewaySessionLocal gatewaySessionLocal;
Documentation clearly states that a web services end-point inside a web container should support injection for an EJB resource type (http://www.onjava.com/pub/a/onjava/2006/01/04/dependency-injection-java-...).
Why is @EJB dependency injection not working for this WebService class? It is in the same WAR as the servlet is.