1 Reply Latest reply on Apr 17, 2005 8:45 AM by hillelzvi

    How to Alias the JNDI name

    Hillel Bilman Newbie

      Goal: Have one stateless session bean with a JNDI name and two aliiases to it.

      Acc http://docs.jboss.org/jbossas/jboss4guide/r2/html/ch3.chapter.html#d0e10124

      3.2.6.2. The org.jboss.naming.NamingAlias MBean

      The NamingAlias MBean is a simple utility service that allows you to create an alias in the form of a JNDI javax.naming.LinkRef from one JNDI name to another. This is similar to a symbolic link in the UNIX file system. To an alias you add a configuration of the NamingAlias MBean to the jboss-service.xml configuration file. The configurable attributes of the NamingAlias service are as follows:

      FromName: The location where the LinkRef is bound under JNDI.
      ToName: The to name of the alias. This is the target name to which the LinkRef refers. The name is a URL, or a name to be resolved relative to the InitialContext, or if the first character of the name is a dot (.), the name is relative to the context in which the link is bound.

      The following example provides a mapping of the JNDI name QueueConnectionFactory to the name ConnectionFactory.


      ConnectionFactory
      QueueConnectionFactory


      So I added to server/default/conf/jboss-service.xml

      34402_EN
      34402



      34402_ID
      34402_EN


      If I look at http://localhost:8080/jmx-console/HtmlAdaptor?action=displayMBeans
      jboss

      * database=localDB,service=Hypersonic
      * fromName=34402,service=NamingAlias
      * fromName=34402_EN,service=NamingAlias
      Probllem:
      I can't connect to connect to the alias JNDI names?

      Using: ctx = new InitialContext();
      obj = ctx.lookup(jndiName);
      or
      ctx = new InitialContext();
      obj = ctx.lookupLink(jndiName);

      Any help how to achieve me goal appreciated.


        • 1. Re: How to Alias the JNDI name
          hillelzvi Newbie

          Hi,

          To clarify I've added to /usr/local/jboss-4.0.1sp1/server/default/conf/jboss-service.xml
          the following:

          <mbean code="org.jboss.naming.NamingAlias"
           name="jboss:service=NamingAlias,fromName=34402">
           <attribute name="ToName">34402_EN</attribute>
           <attribute name="FromName">34402</attribute>
           </mbean>
          
           <mbean code="org.jboss.naming.NamingAlias"
           name="jboss:service=NamingAlias,fromName=34402_EN">
           <attribute name="ToName">34402_ID</attribute>
           <attribute name="FromName">34402_EN</attribute>
           </mbean>


          There aliases are viewable via the Jboss JMX Management console under the
          Jboss heading:

          * fromName=34402,service=NamingAlias
          * fromName=34402_EN,service=NamingAlias

          But I can't connect to the aliases via :
          ctx = new InitialContext();
          obj = ctx.lookup(34402_EN); or obj = ctx.lookupLink(34402_EN);
          or obj = ctx.lookup(34402_ID); or obj = ctx.lookupLink(34402_ID);

          How does one set-up JNDI aliases and then connect to the aliases?