How can I specify my jndi.properties & other config file are in same directory?

17 views
Skip to first unread message

vikas.khengare

unread,
May 14, 2008, 9:45:22 AM5/14/08
to osjava
Hi Friends,

I have my "jndi.properties" file in CLASSPATH. The "jndi.properties"
contents are below

java.naming.factory.initial=org.osjava.sj.SimpleContextFactory
# absolute directory, using the default file protocol
org.osjava.sj.root=.

"org.osjava.sj.root" this variable I set with dot (.) means current
directory.
but it is throwing error saying "Failed to access Data Source: java:/
myDS".

Can you suggest that, how I should refer current directory to have my
all configuration file in same directory including "jndi.properties"?

Thanks

regards
Vikas Khengare

Henri Yandell

unread,
May 28, 2008, 3:01:27 AM5/28/08
to osj...@googlegroups.com
You can easily have the two in the same directory by having:

config/
config/jndi.properties
config/myDS.properties

where your classpath contains config/, and org.osjava.sj.root is config/

Having it in the current working directory - I'm less sure of. I'd try:

org.osjava.sj.root=./

Hen

vikas khengare

unread,
May 28, 2008, 5:27:22 AM5/28/08
to osj...@googlegroups.com
Thanks for your reply.

I have done it.

My config directory have only 2 files ie
      config/default.properties
      config/jndi.properties

config/ is in my CLASSPATH.

"default.properties" contains

myDS.type=javax.sql.DataSource
myDS.driver=com.mysql.jdbc.Driver
myDS.url=jdbc:mysql://localhost:3306/mydb
myDS.user=root
myDS.password=root


and my "jndi.properties" contains

java.naming.factory.initial=org.osjava.sj.SimpleContextFactory
org.osjava.sj.root=file://./config/

Thanks for your help

regards
vikas khengare
--
Vikas
[ vikas.k...@gmail.com ]
Reply all
Reply to author
Forward
0 new messages