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.
Thanks Jon. I read the first part of the article and also found another link- http://firstname.lastname@example.orgemail@example.com/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?
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.
Yes, I am confused. I looked back the ejb-jar file, it should be
|--> for remote case
so I should edit the Jboss.xml to
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?
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.
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.
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?