aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes JNDI Concepts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JNDI Concepts" Watch "JNDI Concepts" New topic
Author

JNDI Concepts

Prakash Dwivedi
Ranch Hand

Joined: Sep 28, 2002
Posts: 452
Nowadays I am studying jndi in detail. I have used JNDI to browse my local file system. What I read about JNDI is that it maintains hierarchical tree like structure, where there is a root context, which may contain one or more sub-context and so on. Also when we write the code in an EJB. What app server does is initializes JNDI with proper drivers,
InitialContext ctx = new InitialContext();


Now my question starts here
I tried following code in my EJB

It prints �localhost/nodes/localhost/servers/server1� (I am using WSAD 5.0 to run this code).

Again when I try

I get javax.naming.NameNotFoundException: localhost/nodes/localhost/servers/server1�

Why is this happening? Also is it possible to parse whole JNDI Tree? If Yes how?


Prakash Dwivedi (SCJP2, SCWCD, SCBCD)
"Failure is not when you fall down, Its only when you don't get up again"
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
I think you should start enumerating things from the initial context. I don't think you need to include the initial context's real name when you try and enumerate its contents, as it thinks you are trying to enumerate "localhost/nodes/localhost/servers/server1/localhost/nodes/localhost/servers/server1" possibly.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
Prakash Dwivedi
Ranch Hand

Joined: Sep 28, 2002
Posts: 452
thnaks Nathaniel,
but InitialContext class doesn't have any list() method with empty parameters. So i need to provide name of the initial context.
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
Ah .. good point. You don't need the prepended "/" or "java:/" ?
Prakash Dwivedi
Ranch Hand

Joined: Sep 28, 2002
Posts: 452
Thanks it worked if i pass empty string
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JNDI Concepts