3 Replies Latest reply on Sep 25, 2008 12:07 PM by David Fuchs

    How To Modify Global JNDI Name

    David Fuchs Newbie

      Hello,

      When accessing one of several EJBs in my EAR through JNDI, the JNDI names are '<ear-name>/<ejb-name>/local'. I can customize <ejb-name> portion through the @Stateless(name=) attribute, but I cannot find a way to change the <ejb-name> part without renaming my EAR file, and I don't want to do this.

      Any ideas? Can I deploy some kind of config file in my EAR to do this?

        • 1. Re: How To Modify Global JNDI Name
          David Fuchs Newbie

          Correction, I cannot find a way to change the <ear-name> part without renaming my ear, not <ejb-name>.

          • 2. Re: How To Modify Global JNDI Name
            jaikiran pai Master

            You can use the JBoss specific @RemoteBinding and @LocalBinding annotations to bind the EJB to the jndi name of your choice.

            @Stateless
            @Local(com.mycomp.MyLocal.class)
            @Remote(com.mycomp.MyRemote.class)
            @LocalBinding(jndiBinding="MyLocalJNDIName")
             @RemoteBinding(jndiBinding="MyRemoteJNDIName")
             public class MyBean implements MyLocal, MyRemote
            {
             ...
            }
            


            For the remote interface, you can use MyRemoteJNDIName in the lookup and for the local interface you can use MyLocalJNDIName.


            • 3. Re: How To Modify Global JNDI Name
              David Fuchs Newbie

              This is exactly what I wanted. Thanks so much for your help!

              I see I no longer need to specify the 'name' in the @Stateless attribute either. This is my Global JNDI Namespace before and after the change:

              Before:

              @Stateless(name="TestEJB")
              @Remote(IPing.class)
              


               +- TestEAR-1.0.0 (class: org.jnp.interfaces.NamingContext)
               | +- TestEJB (class: org.jnp.interfaces.NamingContext)
               | | +- remote (proxy: $Proxy161 implements interface test.IPing,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
              


              After:
              @Stateless
              @Remote(IPing.class)
              @RemoteBinding(jndiBinding="TestEAR/TestEJB/remote")
              


               +- TestEAR (class: org.jnp.interfaces.NamingContext)
               | +- TestEJB (class: org.jnp.interfaces.NamingContext)
               | | +- remote (proxy: $Proxy177 implements interface test.Ping,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)