Link to home
Start Free TrialLog in
Avatar of jaggernat
jaggernat

asked on

jndi basics

hi experts

have this question

In ejbs,  the client program (which is trying to access an ejb) has the jndi lookup which goes like this

InitialContext ic = new InitialContext()
Object obj = ic.lookup("blabla");
StudentHome home =(StudentHome) PortableRemoteObject.narrow(blabla,StudentHome.class);
StudentRemote remote= home.create();


my question is ,
I know jndi is used to look up different resources, but what exactly does jndi look up in the above statement.
i want to know how exactly  jndi ( in above program) communicates with the component deployed in the server.


thanks

J
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jaggernat
jaggernat

ASKER

ok , but where is "blabla" in the component. Is it the HomeInterface or is it the RemoteInterface or anything else.

thanks for prompt response,
J
It could be anything

the following should help

http://java.sun.com/products/jndi/tutorial/
thats a huge tutorial .   ok , how is jndi   related to homeinterface or remote interface that we create in the ejb component .


thanks,
J
jndi is the lookup mechanism used to locate the required objects

http://java.sun.com/products/jndi/tutorial/getStarted/examples/naming.html
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
so ejb/com/package/HelloHome is the jndi name of ejb class.  right

> Object obj = prop.lookup("ejb/com/package/HelloHome");

that should be the following shouldn't it?

Object obj = prop.lookup("java:comp/ejb/com/package/HelloHome");


if you are more intested in EJB as opposed to JNDI then theres an example here:

http://publib.boulder.ibm.com/infocenter/ws60help/index.jsp?topic=/com.ibm.websphere.nd.doc/info/ae/ae/rnam_example_prop3.html
>> that should be the following shouldn't it?

It could be anything, depending upon the server. For example, in Websphere, you could perform look-up on "WFInd.MaintenanceService" where WFInd.MaintenanceService is defined in ibm-ejb-jar-bnd.xmi as:

  <ejbBindings xmi:id="MaintenanceService_Bnd" jndiName="WFInd.MaintenanceService">
    <enterpriseBean xmi:type="ejb:Session" href="META-INF/ejb-jar.xml#MaintenanceService"/>
  </ejbBindings>

This would search for <ejb-name>MaintenanceService</ejb-name> in ejb-jar.xml.
>  so ejb/com/package/HelloHome is the jndi name of ejb class.  right

Yes thats correct =)