Can CDI inject remote instances of my Bean?
Asked Answered
U

1

5

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?

Undertow answered 17/6, 2011 at 3:47 Comment(0)
B
7

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.

Bolshevism answered 17/6, 2011 at 15:14 Comment(2)
What about a non-portable solution? I'm particularly interested if Wildfly has something for that.Outplay
Sorry, I don't know. I recommend opening a new question and then linking it in the comments here.Bolshevism

© 2022 - 2024 — McMap. All rights reserved.