Why aren't any properties loading from jndi.properties?

L

laredotornado

Hi,

I'm creating a web application (WAR) for a server running a Java 1.5
VM. Although I have verified that my file, jndi.properties, is part
of my WAR file (file located within the classes directory), this code

InitialContext ctx = new InitialContext();
final String val = (String) ctx.lookup(property);
LOGGER.info("lookup " + property + "=" + val);

fails to retrieve any properties (for each lookup, a null is returned
every time). What am I missing? I thought the documentation said
that as long as I included jndi.properties somewhere in my classpath,
I would be able to read properties from the file --
http://java.sun.com/products/jndi/tutorial/beyond/env/source.html ?

Thanks for any advice, - Dave
 
M

markspace

laredotornado said:
every time). What am I missing? I thought the documentation said
that as long as I included jndi.properties somewhere in my classpath,
I would be able to read properties from the file --
http://java.sun.com/products/jndi/tutorial/beyond/env/source.html ?


That documentation, to me, says that resources on the class path are
located, but I don't see where it says that about the JNDI server itself:

"The JNDI automatically reads the application resource files from all
components in the applications' classpaths and
JAVA_HOME/lib/jndi.properties..."

"automatically reads the application resource files" is the key.
Resource files are located, JNDI is not. That line follows about 5
lines of configuration for JNDI, so I assume you need something like
that to locate and instantiate the server connection.

Do you have such a configuration? Where is it (file and sub-dirs/WAR
paths)? What's in that config file?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top