Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNDI Concepts

 
Prakash Dwivedi
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Prakash Dwivedi
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah .. good point. You don't need the prepended "/" or "java:/" ?
 
Prakash Dwivedi
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks it worked if i pass empty string
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic