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.


LVL 10
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.

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

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,
It could be anything

the following should help

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 .

jndi is the lookup mechanism used to locate the required objects

> 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.PROVIDER_URL, "corbaloc:iiop:localhost:2809");
Context prop = new InitialContext(home);
Object obj = prop.lookup("ejb/com/package/HelloHome");

Hope that helps . . .
jaggernatAuthor Commented:
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:

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"/>

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 =)
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.