Can CDI inject EJB references in my remote EJB client?
Actually I've a JUnit test case that runs locally on my system and access a EJB running on a standalone JBoss AS. I'm currently using JNDI to access remote business interface of the bean and testing the same.
I would like to know, If @Inject can help me here injecting my EJB instance directly to my test case so that I could avoid JNDI lookups and still access the EJB?
Not portably. From the CDI specification:
The unrestricted set of bean types for a session bean contains all local interfaces of the bean and their superinterfaces. If the session bean has a bean class local view, the unrestricted set of bean types contains the bean class and all superclasses. In addition, java.lang.Object is a bean type of every session bean.
Remote interfaces are not included in the set of bean types.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With