getting localhome from external war in the same VM fails:add
rolivawdaneel Aug 19, 2002 1:07 AM** MY GOAL:
Get via JNDI, a local home of an EJB from a .war external to the target ejb's .jar, but residing in the same container.
** PROBLEM ENCOUNTERED:
org.jboss.deployment.DeploymentException: ejb-local-ref: ejb/appName/beanName, target not found, add valid ejb-link [...]
** PREVIOUS POSTS ABOUT THE TOPIC:
http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ got it working but with the .war within the .jar
-frank proposed something for accessing ejb outside the .jar: not to bind the ejb in web.xml/jboss-web.xml at all and call it via the jndi name local/[ejb name]. I tried and JNDI sait "local not bound", and I can see in the JNDI tree that local context is not there...
http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ post is about exactly the same problem then mine, but is unaswered.
http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ situation than first thread link
http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ very helpful
** QUESTIONS/REQUESTS
- Could someone post in this thread a working example of a servlet accessing an EJB residing in a different jar but in the same VM, with ejb-jar.xml, jboss-web.xml, web client's java source (JNDI lookup part), web.xml, jboss.xml? I can see that other people had the same problem, and this thread could become a reference for those who experience the same problem in the future if we could get a workable example.
- The <ejb-link> tag is the one I am the most uncertain. I saw two syntax: <ejb-link>[bean name]</ejb-link> and <ejb-link>[path-to-.jar]#[bean name]</ejb-link>. Why there is 2 syntaxes? When should we use the first and when the other? The tag is optional, why? When should we use it, and when we should't? I read the path-to-.jar is relative to .war, but if I have:
-+-MyEJBs.jar
|
+-MyWebApp.war
Should I write ../MyEJB.jar or MyEJB.jar (or, on win32 ..\\MyEJB.jar or ..\MyEJB.jar)?
- Any idea why my ejb is not bound to "local/[ejb name]" context by default?
- A more "theorical" question: the container already got the jndi name in jboss-web.xml, why does it need a <ejb-link>?
** NOTES
Thank you in advance for your help. Feel free to check my tests. When I tried many possibilities, they are in comments to show you what I have tried.
** SOURCE: web.xml
...
<ejb-local-ref>
<ejb-ref-name>ejb/ciscoipphonenetworkweb/Telephone</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>ca.bell.iptelephony.ciscoipphonenetwork.interfaces.TelephoneLocalHome</local-home>
ca.bell.iptelephony.ciscoipphonenetwork.interfaces.TelephoneLocal
<!-- <ejb-link>ciscoipphonenetwork/Telephone</ejb-link> -->
<!-- <ejb-link>ejb-ciscoipphonenetwork-1.1.jar#ciscoipphonenetwork/Telephone</ejb-link> -->
<ejb-link>C:\\jboss-3.0.0\\server\\default\\deploy\\ejb-ciscoipphonenetwork-1.1.jar#ciscoipphonenetwork/Telephone</ejb-link>
</ejb-local-ref>
...
** SOURCE: jboss-web.xml
...
<ejb-ref>
<ejb-ref-name>ejb/ciscoipphonenetworkweb/Telephone</ejb-ref-name>
<jndi-name>ejb/ciscoipphonenetwork/Telephone</jndi-name>
</ejb-ref>
...
** SOURCE: ejb-jar.xml
...
<![CDATA[An IP telephone representation]]>
<display-name>An IP telephone representation</display-name>
<ejb-name>ciscoipphonenetwork/Telephone</ejb-name>
<local-home>ca.bell.iptelephony.ciscoipphonenetwork.interfaces.TelephoneLocalHome</local-home>
ca.bell.iptelephony.ciscoipphonenetwork.interfaces.TelephoneLocal
<ejb-class>ca.bell.iptelephony.ciscoipphonenetwork.entity.TelephoneCMP</ejb-class>
...
** SOURCE: jboss.xml
...
<ejb-name>ciscoipphonenetwork/Telephone</ejb-name>
<local-jndi-name>ejb/ciscoipphonenetwork/Telephone</local-jndi-name>
...
** SOURCE: JNDI lookup
...
try
{
Context ctx = new InitialContext();
TelephoneLocalHome telephoneLocalHome = (TelephoneLocalHome)ctx.lookup("java:comp/env/ejb/ciscoipphonenetworkweb/Telephone");
//TelephoneLocalHome telephoneLocalHome = (TelephoneLocalHome)ctx.lookup("local/ciscoipphonenetwork/Telephone");