• Post Reply Bookmark Topic Watch Topic
  • New Topic

Setting JNDI Properties doesn't work  RSS feed

 
Mani Ram
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I set the java.naming.factory.initial and java.naming.provider.url properties in jndi.properties file, everything works fine.
But if I specify it in my program using the following code,

javax.naming.NoInitialContextException is thrown!
Setting the properties in command line (java -D option) also doesn't work.
What might be the problem?
 
Sri Basavanahally
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may want use java.util Properties instead of the hash.
ex:
Properties prop = new Properties();
prop.put(the context...)
prop.put(the url...)
then use prop in your intial context.
Hope that helps
-Sri
 
Sri Basavanahally
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may want use java.util Properties instead of the hash.
ex:
Properties prop = new Properties();
prop.put(the context...)
prop.put(the url...)
then use prop in your intial context.
Hope that helps
-Sri
 
Mani Ram
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sri Basavanahally:
You may want use java.util Properties instead of the hash.

That shouldn't matter. Anyhow, I have tried with Properties also, and it doesn't work either.
 
Mani Ram
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. Supplying the properties throgh command line or using System.setProperty() works.
But why setting the InitialContext is not working?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!