6 Replies Latest reply on Aug 13, 2009 7:04 PM by Peter Johnson

    Understand JNDI naming convention

    Mohit Anchlia Novice

      Jboss 4.2:

      I always have hard time understanding JNDI naming convention. I try to understand one way or the other but next time when I look at them it again leads to more confusing. I have hard time understanding

      1. concept of java:/comp compared to mapped-by name.
      2. Also what Global JNDI is.
      3. When I look in JNDI view of jmx-console I see something like

      e.cache:service=CacheLoader


      I don't know what those ":" and "." and "=" are for. How to interpret that whole string. Is it just the unique string or does ".", ":" and "=" have some special meaning.

        • 1. Re: Understand JNDI naming convention
          Peter Johnson Master

          1) For each web app deployed to the app server there is a "java:comp" namespace whose content is accessible only by that app. The app server prefills some names but you have to do some work (such as add resource-ref entries to your web.xml) to get others.

          mapped-name for what? In an @Stateless annotation? In an @EJB annotation? mapped-name is usually the full JNDI name (usefull for referencing the global namespace) while name is within the "java:" namespace for the app.

          2) Names in the global namespace are accessible from remote clients (that is, running in a separate JVM) - remote clients cannot access names in "java:*". For example, if a remote client needs access to an EJB, it must look up the name in the global namespace.

          3) You never said exactly where you are seeing this entry (I don't see it), but if it is part of the description for a"java:comp" then it is the name of the MBean name created for the application. MBean names have the pattern:

          <namespace>:<key-value-pair>[,<key-value-pair>]*


          so in your case "e.cache" is the namespace, and there is only one key-value pair "service=CacheLoader"

          • 2. Re: Understand JNDI naming convention
            Mohit Anchlia Novice

            Thanks! What's the difference between java:comp and java:com/env?

            Also, regarding my second question who uses the namespace? For eg: In jmx console under jboss.j2ee I see:

            jar=efe-messaging.jar,name=RouterBean,service=EJB3
            
            
            I am not sure why it's defined this way? And also is name= really JNDI name?
            
            Pardon me if I am asking abvious questions.
            


            • 3. Re: Understand JNDI naming convention
              Mohit Anchlia Novice

              My previous post is not formatter correctly

              Thanks! What's the difference between java:comp and java:com/env?

              Also, regarding my second question who uses the namespace? For eg: In jmx console under jboss.j2ee I see:

              jar=ee-messaging.jar,name=RouterBean,service=EJB3
              


              I am not sure why it's defined this way? And also is name= really JNDI name?

              Pardon me if I am asking abvious questions.


              • 4. Re: Understand JNDI naming convention
                Peter Johnson Master

                java:comp/env is the enterprise naming context (ENC) and contains entries from the resource-ref section of your web.xml file.

                regarding my second question who uses the namespace?


                I hope you mean your third question. The namespace (within an MBean name) has no special meaning - it is simply used as a convenience to prevent naming conflicts among MBeans.

                I am not sure why it's defined this way?


                JBoss AS uses a specific pattern for MBean names that it generates, though it uses different patterns for different items. For example, servlets use one MBean name pattern while EJBs use another. What you showed was part of an MBean name for an EJB (there is more to it on the prior line in the jmx-console output)

                And also is name= really JNDI name?


                Not necessarily. It all depends on how the MBean is defined and named.

                • 5. Re: Understand JNDI naming convention
                  Mohit Anchlia Novice

                  ok ..starting to make little sense:

                  jar=ee-messaging.jar,name=RouterBean,service=EJB3
                  


                  So if I see something like this (above) it really means this is a Mbean managing "RouterBean" in this example? So for every Bean there is a Mbean that is created to manage the resource? Am I saying it right?

                  • 6. Re: Understand JNDI naming convention
                    Peter Johnson Master

                    Yes, that is correct. And if you go into the jmx-console you can see that MBean, and if you examine the MBean you might see some interesting data regarding your EJB (such as response times).