2 Replies Latest reply on Feb 22, 2012 10:25 PM by Stephen Coy

    JNDI binding from deployment descriptors

    Stephen Coy Master

      Hi there,

       

      I was reading the AS7.1 JNDI Reference when I encountered the following interesting fragment under the headings Binding entries to JNDI / Using a deployment descriptor:

       

      {code:xml}

          <env-entry>

              <env-entry-name>java:global/mystring</env-entry-name>

              <env-entry-type>java.lang.String</env-entry-type>

              <env-entry-value>Hello World</env-entry-value>

          </env-entry>

      {code}

       

      This looks like a useful thing to do (binding stuff into the global JNDI namespace from a deployment descriptor) and the docs imply that this is spec compliant behaviour.

       

      However, I've trawled through both the "Java™ Platform, Enterprise Edition (Java EE) Specification, v6" and "Java™ Servlet Specification Version 3.0 Rev a" and they both say that the specified env-entry-name is a component relative name (ie. relative to java:comp/env/).

       

      So, is this a JBoss extension? Or is this behaviour specified somewhere that I've not looked?

        • 1. Re: JNDI binding from deployment descriptors
          jaikiran pai Master

          Stephen Coy wrote:

           

           

          So, is this a JBoss extension? Or is this behaviour specified somewhere that I've not looked?

          It's a spec mandated behaviour. Section EE.5.2.1 of Java EE 6 spec has the details which includes:

           

          By default, environment entries declared by application components are created in the java:comp/env namespace. Environment entries may be declared in any one of the defined namespaces by explicitly including the namespace prefix before the name.

          • 2. Re: JNDI binding from deployment descriptors
            Stephen Coy Master

            My document search for "env-entry-name" was a miserable failure here  .

             

            After reading this content I can see that the example in the documentation should probably read:

             

            {code:xml}

                    <env-entry-name>java:global/env/mystring</env-entry-name>

            {code}

             

            so I can fix that if there's no objections.