• Post Reply Bookmark Topic Watch Topic
  • New Topic

NoInitialContextException  RSS feed

 
Andrew Lit
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i've read the tutorial herehere. It is said that i must follow 3 steps, but i stuck with number 1:
Select the service provider of the corresponding service you want to access.
Where can i get that servie provider list or smth to make this tiny program to cimpile.

thank you in advance
 
Amol Desai
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You can find them at
http://java.sun.com/products/jndi/
-Amol
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi andrew,
just 2 cents.
u can compile ur code w/o actually having the Provider but u won't be able to RUN the code beacuse it will go look for the provider at Runtime...
in ur code i noticed that i don't see the line,
env.put(Context.PROVIDER_URL, "file://somepath");
without the PROVIDER_URL it won't find the Object u want to search as PROVIDER_URL is the Context where it starts looking for the given named object..
also, u can find the file system provider from the link Amol provided...
regards
maulin
 
Andrew Lit
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Amol Desai:
Hi,
You can find them at
http://java.sun.com/products/jndi/
-Amol

so i downloaded the class libraries and what should i do then? add them into the classpath?
 
Cory Wilkerson
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are we sure he needs an URL -- he's using the file system service provider. If the appropriate classes are in your path...you should be able to look up stuff via the rest of the tutorial (I assume you're looking at: http://java.sun.com/products/jndi/tutorial/getStarted/examples/naming.html).
I'll give it a shot.
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Cory,
look at the line in my code,
env.put(Context.PROVIDER_URL, "file://somepath");

it is "file://..." as a Provider URL...so it works for local file.
i made sure that we must write Provider URL even to access the File System else otherwise there is no default folder where lookup() searches things from...
thanks
maulin
 
Cory Wilkerson
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K, go here: http://java.sun.com/webapps/download/DisplayLinks and download the File System Service Provider. Several providers are distributed with JDK 1.4, File System does not happen to be one of them.
Write some code that looks like this (notice, we didn't need an URL but you could force one on it):

This obviously assumes you're on a windows box -- but, if you compile and run the thing now with the jars that are distributed with File System Service Provider -- you'll see magic.
Sun tutorials are a joke.
[ June 12, 2003: Message edited by: Cory Wilkerson ]
 
Cory Wilkerson
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Damn, bad link: http://java.sun.com/products/jndi/index.html#download
 
Andrew Lit
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you guys it works
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!