1 Reply Latest reply on Oct 8, 2004 7:38 AM by Kabir Khan

    Application properties stored in jndi.properties

    Paul Smith Newbie

      I want to add a couple of configurable properties to my application. I have been told to add these to the JNDI tree.

      I have put the jndi.properties in the root of my jar. The contents of the jndi.properties are:
      MyKey="keyvalue"

      (No "java:" or anything)

      In my class (not an EJB, just a pojo), I do:

      InitialContext ctx = new InitialContext();
      strKeyValue = (java.lang.String)context.lookup("MyKey");

      The second of these calls results in a NamingException.

      After I start JBoss, I went to the JMX console and could find no mention of "MyKey" on the JNDI page.

      Could someone explain to me what I need to do -
      Where should the jndi.properties go for JBoss to add it to the JNDI tree?
      Does the format of the key need to have a "java:" on the front or anything like that?

      Thanks in advance,
      Paul

        • 1. Re: Application properties stored in jndi.properties
          Kabir Khan Master

          The jndi.properties file is for configuring the jndi system, i.e tell it where the JNDI server is etc. In other words you do not bing your properties there.

          To bind stuff to JNDI, you need to do something along the lines of:

           String myname = "something/test/TestObj";
           Object obj = "Xyz";
           InitialContext ctx = new InitialContext();
           Name name = ctx.getNameParser("").parse(myname);
           ctx.bind(name, obj);
          


          (java: at the start of a name means that the property should not be accessible outside the JVM)