2 Replies Latest reply on Feb 11, 2002 9:06 AM by Ramón Talavera

    QUESTION:Packaging and deploying the Beans

    Ramón Talavera Newbie

      In the tutorial section:
      Packaging and deploying the Beans
      in the deployment descriptor ejb-jar.xml we find:
      ...

      <ejb-name>CDBean</ejb-name>
      ...

      ...

      <ejb-ref-name>ejb/CD</ejb-ref-name> <-REFERENCE TO JNDI?
      ...


      I thought it is a reference to CDBean using jndi BUT
      In the JBoss run-time configuration file "jboss.xml" :

      <ejb-name>CDBean</ejb-name>
      <jndi-name>cd/CD</jndi-name> <-- LOOK cd/CD
      <configuration-name></configuration-name>


      So how does the <ejb-ref-name>ejb/CD find such class?


      Please help me. :)
      Sincerely
      Ramón Talavera

        • 1. Re: QUESTION:Packaging and deploying the Beans
          Horia Muntean Newbie

          In ejb-jar.xml u have

          ...
          <ejb-name>CDBean</ejb-name>
          ...

          and

          ....
          <ejb-ref>
          <ejb-ref-name>ejb/CD</ejb-ref-name>
          <ejb-ref-type>Entity</ejb-ref-type>
          org.jboss.docs.cmp.cd.interfaces.CDHome
          org.jboss.docs.cmp.cd.interfaces.CD
          <ejb-link>CDBean</ejb-link>
          </ejb-ref>
          ....

          the <ejb-ref-name>ejb/CD</ejb-ref-name> from the session description is the name used by the session bean code to locate the home of the entity:

          Context initial = new InitialContext();
          initial.lookup("ejb/CD");

          <ejb-link> label is taken into account by the deployer to find the real entity bean. ejb/CD is private to the session bean. u can write anything instead of ejb/CD as long as u use the same path in the session bean code when u locate the home interface of the enrity bean:

          <ejb-ref-name>bla/bla/bla/bla</ejb-ref-name>
          and in code
          Context initial = new InitialContext();
          initial.lookup("bla/bla/bla/bla");

          Furter, suppose u have another session bean that uses the entity bean, u can have:

          <ejb-ref-name>xxx/xxx/xxx</ejb-ref-name>
          and in code
          Context initial = new InitialContext();
          initial.lookup("xxx/xxx/xxx");

          but <ejb-link>CDBean</ejb-link> has to remain the same.


          In jboss.xml u have

          <ejb-name>CDBean</ejb-name>
          <jndi-name>cd/CD</jndi-name>
          <configuration-name></configuration-name>

          here is the real jndi name of the entity bean.if u want to access the entity bean directly (from a client and not from another session bean) u'll have to use this name to locate the home interface.