Finding a JNDI can be important in the case of SFSB (be sure to refer to the same instance all the time), but in the case of SLSB I am not aware of cases where JNDI will be "better" in any way.
I would definitely go with @EJB . Itβs easier to read (less error prone code), easier to maintain (you care about the location of the JNDI namespace for the bean), and easier to test (without the nasty search code that needs to be disabled when performing unit tests).
Speaking of efficiency - I'm not 100% sure, but I wonβt be surprised if it happens that the application server actually performs JNDI searches behind the scenes when using annotations.
source share