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
LVL 10
jaggernatAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

objectsCommented:
It looks up the object named "blabla".
Where this look up is done (the context) needs to be defined in your system properties
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jaggernatAuthor Commented:
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
0
objectsCommented:
It could be anything

the following should help

http://java.sun.com/products/jndi/tutorial/
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

jaggernatAuthor Commented:
thats a huge tutorial .   ok , how is jndi   related to homeinterface or remote interface that we create in the ejb component .


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

http://java.sun.com/products/jndi/tutorial/getStarted/examples/naming.html
0
JavatmCommented:
> how is jndi related to homeinterface or remote interface that we create in the ejb component.

Actually Context lookup is looking for the " jndi name " of the ejb class that you want to run. The properties that
you set for your initial context will vary to the type of server that you use, here is an example :

Properties home = new Properties();

// This will be different depending on your server. WAS for WSAD
home.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
home.put(Context.PROVIDER_URL, "corbaloc:iiop:localhost:2809");
                  
Context prop = new InitialContext(home);
Object obj = prop.lookup("ejb/com/package/HelloHome");
System.out.println(obj);

Hope that helps . . .
Javatm
0
jaggernatAuthor Commented:
so ejb/com/package/HelloHome is the jndi name of ejb class.  right

0
objectsCommented:
> 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
0
Mayank SAssociate Director - Product EngineeringCommented:
>> 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.
0
JavatmCommented:
>  so ejb/com/package/HelloHome is the jndi name of ejb class.  right

Yes thats correct =)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.