7 Replies Latest reply on Nov 14, 2003 6:28 PM by jbossuserr

    Local ref entity bean not bound

    jbossuserr Newbie

      I have the following DDs,

      in ejb-jar.xml


      <ejb-name>AEnt</ejb-name>
      :

      <ejb-local-ref>
      <ejb-ref-name>ejb/BEnt<ejb-ref-name>
      <local-home>...
      ...
      <ejb-link>BEnt</ejb-link>
      :


      in Jboss.xml

      <ejb-name>AEnt</ejb-name>
      <local-jndi-name>AEntLocal</local-jndi-name>

      <ejb-name>BEnt</ejb-name>
      <local-jndi-name>BEntLocal</local-jndi-name>


      In Application, A is looking up B's home object by

      BEntHome= (BEntHomeLocal) context.lookup("java:comp/env/ejb/BEntLocal")


      I read the documentation that if Bean A and B in the same deployment unit, in the same ear file and if there is <ejb-link> tag in ejb-jar.xml, there is no need to add <ejb-ref> in jboss.xml,

      but I kept getting BEntLocal not bound during runtime when Bean A is trying to look up B' home object.


      Do I have to add <ejb-ref> in Jboss.xml to map the ejb ref name to jndi name explicitly? or I overlooked something else?

      Thanks.



        • 1. Re: Local ref entity bean not bound
          Jon Barnett Master

          Don't use link if referencing by ejb-ref-name. Also sanity check via JNDIView in jmx-console. Check http://www.amitysolutions.com.au/documents/JBossJNDI-technote.pdf for an in-depth starting point.

          Hope it helps.

          • 2. Re: Local ref entity bean not bound
            jbossuserr Newbie

            Thanks Jon. I read the first part of the article and also found another link- http://www.mail-archive.com/jboss-development@lists.sourceforge.net/msg36491.html//www.mail-archive.com/jboss-development@lists.sourceforge.net/msg36491.html with similar topic. The j2ee application I have does not allow to make change (like remove ejb-link), I am sure Bean A and B are packaged in the same ear file, my question is that with ejb-link in ejb-jar file and without ejb-ref in jboss.xml and it did not work, does that mean this is a bug?

            Thanks.

            • 3. Re: Local ref entity bean not bound
              Jon Barnett Master

              Not necessarily. ejb-link points to a corresponding ejb-name tag. If your beans deployed, then the deployment descriptor constructs are well-formed from the JBoss validation.

              However, look carefully at your reference chain. You declare your internal reference point as ejb/BEnt, but your lookup is java:comp/env/ejb/BEntLocal -> ejb-ref-name:ejb/BEntLocal -> ?.

              So you want the chain:
              java:comp/env/ejb/BEnt -> ejb-ref-name:ejb/BEnt -> ejb-link:BEnt -> ejb-name:BEnt.

              You've probably made things a bit confusing through the naming.

              As a side issue, it is strange that your application does not allow the removal of the ejb-link tag as it is not mandatory.

              • 4. Re: Local ref entity bean not bound
                jbossuserr Newbie

                Yes, I am confused. I looked back the ejb-jar file, it should be


                <ejb-name>AEnt</ejb-name>
                :

                <ejb-local-ref>
                <ejb-ref-name>ejb/BEntLocal<ejb-ref-name>
                <local-home>...
                ...
                <ejb-link>BEnt</ejb-link>
                :
                |--> for remote case

                <ejb-ref>
                <ejb-ref-name>ejb/CEnt<ejb-ref-name>
                ...
                ...
                <ejb-link>CEnt</ejb-link>




                so I should edit the Jboss.xml to


                <ejb-name>AEnt</ejb-name>
                <local-jndi-name>AEntLocal</local-jndi-name>
                :
                <ejb-local-ref>
                <ejb-ref-name>ejb/BEntLocal</ejb-name>
                <local-jndi-name>BEntLocal</local-jndi-name>
                </ejb-local-ref>

                <ejb-ref>
                <ejb-ref-name>ejb/CEnt</ejb-name>
                <jndi-name>CEnt</jndi-name>
                </ejb-ref>

                I still dont quite understand what is the purpose of using <ejb-link> in the case of local interface when it points to the referenced EJB object but not the home object?

                Thanks.

                • 5. Re: Local ref entity bean not bound
                  Jon Barnett Master

                  ejb-link does not require anything on the jboss.xml unless all the beans are packaged in the same JAR.

                  ejb-jar.xml for bean BSes:

                   <session >
                   <ejb-name>BSes</ejb-name>
                   ...
                   </session>
                  

                  jboss-xml for bean BSes:
                   <session>
                   <ejb-name>BSes</ejb-name>
                   <jndi-name>ejb/remote/BSes</jndi-name>
                   <local-jndi-name>ejb/local/BSes</local-jndi-name>
                   <configuration-name>Standard Stateless SessionBean</configuration-name>
                   <method-attributes>
                   </method-attributes>
                   </session>
                  

                  ejb-jar.xml for ASes:
                   <session >
                   <ejb-name>ASes</ejb-name>
                   <home>org.my.ASesHome</home>
                   <remote>org.my.ASes</remote>
                   <local-home>org.my.ASesLocalHome</local-home>
                   <local>org.my.ASesLocal</local>
                   <ejb-class>org.my.ASesBean</ejb-class>
                   <session-type>Stateless</session-type>
                   <transaction-type>Bean</transaction-type>
                   <ejb-local-ref >
                   <ejb-ref-name>ejb/BSes</ejb-ref-name>
                   <ejb-ref-type>Session</ejb-ref-type>
                   <local-home>org.my.BSesHome</local-home>
                   <local>org.my.BSesLocal</local>
                   <ejb-link>BSes</ejb-link>
                   </ejb-local-ref>
                   </session>
                  

                  Nothing should be required in jboss.xml for ASes that refers to BSes assuming that the two EJBs are in separate JARs.

                  ejb-link:BSes -> ejb-name:BSes

                  Note that this refers to the whole physical EJB - but you state by ejb-local-ref that you are interested in the local home. And since you are implicitly stating through the use of ejb-link that the ejb-name BSes is known within the relevant scope.
                  e.g. in the same Application or in the same package.

                  Hope that makes sense.

                  • 6. Re: Local ref entity bean not bound
                    jbossuserr Newbie

                    What you have suggested from the previous mail was what I have done the first time. I looked the Jboss version of O'Reilly Titan example, it seems to me that I have to map the jndi or local-jndi name in the jboss.xml to the ejb-name in ejb-jar.xml, so I added all the jndi or local-jndi names to Jboss.xml for all the session or entity beans appearing in ejb-jar.xml without any ejb-ref or ejb-local-ref elements defined in Jboss.xml. But I kept getting "not bound" from one of local ref entity beans, that's why I entered this question in this forum.

                    After I added ejb-ref (for remote interface) and ejb-local-ref(for home interface) in jboss.xml and before I saw your latest reply, I tested it and it still failed with the same error, like you said and what I read, ejb-ref and ejb-ref-local were not needed in this case, I must miss something else then. The server log file did indicate that the local ref entity bean was bound to the jndi name. and JMX console also showed the jndi name.

                    Thanks for your help, I still have to find out what the problem is.

                    • 7. Re: Local ref entity bean not bound
                      jbossuserr Newbie

                      Tracing back the server log, the error before the "not bound", I had "[org.jboss.ejb.plugins.AbstractInstanceCache] Activation failure", Can someone explain what this means? Is it possible the reason that the local entity bean was not bound was due to the CMRs were not defined correctly?

                      Thanks.