javaejb-3.0jndiwildfly-8ejb-3.2

@LocalBinding(jndiBinding="sample/student") of EJB 3.0 not present in EJB 3.2


@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.


Solution

  • 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.