Originally posted by Rick Reumann:
As far as I know, using JBoss I can't use the @EJB annotation to inject an EJB into a non EJB object (like a servlet.) It also seems to only work for local EJBs. I guess I'll post on the jboss forums, unless someone else could provide some info..
from http://trailblazer.demo.jboss.com/EJB3Trail/serviceobjects/injection/
Please note that EJB 3.0 dependency injection annotations only works in EJB objects -- not generic POJOs. For instance, you cannot use the dependency injection annotations in a servlet to obtain session bean objects. In addition, EJB 3.0 dependency injection only works in the local JNDI. Hence you cannot inject objects from remote servers.
Then it isn't
Java EE 5 compliant. The spec requires that injection of resources be allowed into the major component classes including servlets, EJBs,
JSF beans, and so on. It doesn't make any sense if you can't inject an EJB into a servlet because then you are left having to do the old-style JNDI lookup and you are effectively stuck in EJB 2.1 land.
I guarantee that if you try it on Glassfish, OC4J or any other Java EE 5 server that supports it properly you'll see how easy it is to use.