JNDI : logical vs physical way

G

gk

I read from a book ....

The logical reference (or alias) java:comp/env/ejb/MyBean is the
recommended approach because you cannot guarantee that the physical
JNDI location ejb/MyBean you specify in your code will be available .
Your code wll break if the physical location is changed

Context ctx = new InitialContext();
Object ref =ctx.lookup("java:comp/env/ejb/MyBean");



My Question:
--------------------

suppose I write my java code this way

Context ctx = new InitialContext();
Object ref =ctx.lookup("ejb/MyBean");// This is physical way


I don't understand this . what change they are talking about ?
are they talking about if I migrate my code to different server ? but
I can create a JNDI with the name "ejb/MyBean" there also in the Admin
server....so, how come the code will break ?

I don't get the concern here and hence don't understand why logical
reference is important here ?

Could you please tell me a case study where the problem could arise ?
when the code will break ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top