• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Setting JNDI Properties doesn't work

 
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
reply
    Bookmark Topic Watch Topic
  • New Topic