?
Solved

jndi basics

Posted on 2005-02-24
10
Medium Priority
?
738 Views
Last Modified: 2013-11-24
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
0
Comment
Question by:jaggernat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 92

Accepted Solution

by:
objects earned 375 total points
ID: 13398163
It looks up the object named "blabla".
Where this look up is done (the context) needs to be defined in your system properties
0
 
LVL 10

Author Comment

by:jaggernat
ID: 13398220
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
 
LVL 92

Expert Comment

by:objects
ID: 13398260
It could be anything

the following should help

http://java.sun.com/products/jndi/tutorial/
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 10

Author Comment

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


thanks,
J
0
 
LVL 92

Expert Comment

by:objects
ID: 13398369
jndi is the lookup mechanism used to locate the required objects

http://java.sun.com/products/jndi/tutorial/getStarted/examples/naming.html
0
 
LVL 15

Assisted Solution

by:Javatm
Javatm earned 375 total points
ID: 13398925
> 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
 
LVL 10

Author Comment

by:jaggernat
ID: 13399061
so ejb/com/package/HelloHome is the jndi name of ejb class.  right

0
 
LVL 92

Expert Comment

by:objects
ID: 13399185
> 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
 
LVL 30

Expert Comment

by:Mayank S
ID: 13401050
>> 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
 
LVL 15

Expert Comment

by:Javatm
ID: 13406651
>  so ejb/com/package/HelloHome is the jndi name of ejb class.  right

Yes thats correct =)
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Suggested Courses
Course of the Month8 days, 20 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question