Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

What is Criteria for providing "Context.PROVIDER_URL," ?  RSS feed

 
prasad kulkarni
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
agree that I can have a Distributed object from JNDI lookup, but before making a lookup I need to write a code as

Hashtable envHash = new Hashtable();
envHash.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
envHash.put(Context.PROVIDER_URL, "iiop://localhost:2809/");
Context context = new InitialContext(envHash);
DataSource source = (DataSource) context.lookup("jndiJdbc");

But what is criteria for providing "Context.PROVIDER_URL" ?
I read from diffferent sites , but I am not getting , where this JNDI service resides?
How can I locate this service & determine that it is working or not?
Suppose I have a Database located on PC_X; then for its looup what should I use "iiop://localhost:2809/" or "iiop://PC_X:2809/" or how can I decide that where is JNDI available on my network? I am getting confused here ...
 
Vinay Raj
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most if not all application servers provide JNDI services. The sample code mentioned in your post is a websphere specific way of connecting to the JNDI namespace available within the websphere application server. The JNDI lookup code is standard but connection protocols vary. For example, websphere uses iiop protocol to connect to its JNDI, weblogic uses t3 protocol. Weblogic URL is t3://localhost:7001.

The criteria for Context.PROVIDER_URL depends upon the application server one wishes to connect to. The JNDI service per say resides in your application server. You will need to look up the specific server documentation for exact lookup settings.

As regards your database example the URL will be iiop://PC_X:2809/ provided the database has a JNDI service exposed on the above mentioned port and uses iiop protocol for connectivity.

I am not sure if other application servers provide ways for finding out details about their JNDI services, Websphere provides a exe in its bin called
dumpnamespace
.
It provides a dump on the console of all objects exposed via JNDI and their corresponding names.
 
prasad kulkarni
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankx Vinay Raj ,

This is exactly what I was searching for.........!!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!