javaejbjava-ee-6ejb-3.1

EJB 3.1 @EJB Injection into POJO


With the new EJB 3.1 spec is it possible to inject an EJB into a pojo? I know in EJB 3.0 the @EJB annotation could be used to inject an EJB but this did not work on simple pojos.

If it is not do I have to look the bean up in JNDI as I know you cannot simple use the new keyword.


Solution

  • Yes, use JNDI lookup.

    Since your POJO is created by you (I assume), the container is not responsible for injecting the dependencies.