Ad

Thursday 13 August 2009

Default JNDI Name for the EJB Bean

In the EJB version prior to 3.0 we need to specify the JNDI name for the EJB to be deployed in the server specific xml file(For weblogicit is weblogic-ejb-jar.xml).But for EJB 3.0 ,server will provide a default JNDI name for the EJB which gets deployed in the server.Hence we need to know the defaut JNDI name in which the server will bind the ejb object in theJNDI tree,so that client application can able to look up the ejb object by using this JNDI Name.

Default JNDI Name for the EJB Bean in Weblogic:
    For weblogic ,the default jndi name will be "java:comp/env/ejb/[Business interface name]"
For instance if the name of the business interface which the EJB has implemented is sampleInterface,then the default jndi name will be "java:comp/env/ejb/sampleInterface".

Default JNDI Name for the EJB Bean in JBOSS:
     For JBOSS,the default jndi Name will be "[Name of the EAR]/[EJB Bean logical Name]/[Business Interface Type]"

  • [Name of the EAR] --The Name of the EAR file which contains the EJB
  • [EJB Bean logical Name]-The logical name of the EJB bean (We normally give the logical name for the EJB bean by using annotation in the bean like @Stateless(name = "SampleBean")
  • [Business Interface Type]-The Business interface can be local or remote which depends if the Client is in the same JVM or in a deifferent JVM.We normaly give this information in the EJB bean by using annotaton like @Local(businterface.class) or @Remote(businterface.class)

For Intstance if the name of the EAR file is SamApp.ear and the logical name of the Ejb bean is sampleBean and if the busines interface is local,then the default JNDI Name will be "SamApp/sampleBean/local "

NOTE:If we want to bind the EJB with the new JNDI Name other than default one,we can do the same by overriding it in Server specific xml File.

No comments:

Post a Comment