0

@LocalBinding(jndiBinding="sample/student") in EJB 3.0 is used to give preferred JNDI name to EJB bean.

And to lookup using defined JNDI name, the code used is

Context c = new InitialContext();
studentBean = (studentlBean) c.lookup("sample/student");

How this can be performed in EJB 3.2 as @LocalBinding is not supported in EJB3.2 wildfly 8 application server. Please help.

sridhar
  • 1,117
  • 5
  • 31
  • 59
  • What is the scenario where you must do a JNDI lookup rather than using injection via @EJB? – Steve C Feb 27 '15 at 02:25
  • For example such scenario: EJB instance is needed in class, but injection can't be performed for this class. May be it is problem of application architecture, but in "real life" such problem is common. – Alexander Fedyukov Feb 28 '15 at 08:21

1 Answers1

0

We have solved this problem through creation of utility class and method, wich calculate correct jndi name by Enterprise bean class. In this method we walk on jndi tree, and check every instance of it. If we found instance of required class then return it to the asked class. On my knowledge javaee give not another variants to take EJB instance by jndi name.