1 Reply Latest reply on Jan 7, 2005 5:12 PM by Weston Price

    Difference between Component Name and JNDI Name

    rzeppa Newbie

      Hello,

      after generating a Home with XDoclet, i get two different constants in this Home class:

      public static final String COMP_NAME="java:comp/env/ejb/TopograhpyPoolManagementService";
       public static final String JNDI_NAME="ejb/TopograhpyPoolManagementService";


      There is one utility class generated for creation of the Home object. This class has a method lookup which uses the comp_name, but if i use this method i get a name not bound exception. If i use the jndi_name it works. But this files are generated by xdoclet and so i doesn't want not modify them.

      Whats the difference betwenn this constants? Why is it not working with the comp constant.

      I'am using JBoss 4.0.

      best regards
      sven

        • 1. Re: Difference between Component Name and JNDI Name
          Weston Price Newbie

          The difference is quite simple:

          The component name in this case represents a name that only makes sense when used withing the context of a managed environment (ie running inside the application server), while the JNDI name is the raw name for the component as it is deployed, basically as it appears globally in the JNDI namespace.

          If you are running outside of the EJB conainter, you would use the JNDI name. If running from within the container you would have to bind the comp name into your deployment descriptor as an EJB reference, this can either be Local or Remote depending upon the type of interaction with the component. There should be a method on the utility class to use the JNDI name as well as the component name in looking up the component.