0 Replies Latest reply on Dec 12, 2002 5:32 PM by Nick Newman

    JNDI usage rules

    Nick Newman Newbie

      I have been trying to learn the "correct" way to use JNDI under various circumstances. It seems to me that there is considerable confusion over how and when properties need to be supplied to the InitialContext. I have come up with the following rules. I would appreciate it if some more knowledgeable person would confirm or refute these rules.

      1) You never supply a Properties object to the constructor of the InitialContext. (If necessary, properties are supplied via the jndi.properties file.)

      2) From within an EJB jar file or a WAR file you never supply any properties at all to the InitialContext. If you need to find something on remote server "foo", you just start the jndi-name with "jnp://foo/".

      3) Only from a stand-alone application is the jndi.properties file required.

      Note that rule (2) runs counter to my (many people's?)initial impression that properties are required to find objects on remote machines.

      Any comments?