I DO NOT have to put <ejb-link> tags in my ejb-jar.xml for
one my ejb's to call another ejb.  I am using the EJB 2.0
CMP stuff.

example:

<entity>
   <ejb-name>Shipment</ejb-name>
   ...
   ...
   <ejb-ref>
       <description>Shipment-has-Contacts</description>
       <ejb-ref-name>ejb/Contact</ejb-ref-name>
       <ejb-ref-type>Entity</ejb-ref-name>
       <home>com.tfc.entity.ejb.ContactHome</home>
       <remote>com.tfc.entity.ejb.Contact</remote>
   </ejb-ref>
</entity>

I can create Contact ejbs within my Shipment ejb now.
Inside a Shipment ejb method:

InitialContext ic = new InitialContext();
ContactHome ch =
(ContactHome)PortableRemoteObject.narrow(ic.loopup("java:comp/env/ejb/Contac
t"),
 
ContactHome.class);
Contact c = ch.create();
// or I could call a ContactHome finder method...

I'm not sure if I need to get a new initial context or
if I can use the EntityContext of the Shipment EJB somehow.

-tim


> -----Original Message-----
> From: Randahl Fink Isaksen [mailto:[EMAIL PROTECTED]]
> Sent: Friday, January 19, 2001 6:04 AM
> To: Orion-Interest
> Subject: RE: Getting the home interface of another EJB from within an
> EJB - PROBLEM SOLVED !!!
> 
> 
> Finally: PROBLEM SOLVED.
> 
> The short hint from Luke Nelson turned out to be the ultimate 
> proof of what
> theese mailing lists are really worth.
> 
> Luke is right, guys. To be able to reference other EJBs from 
> within EJBs you
> need to put a <ejb-link> tag in your ejb-jar.xml file. How 
> this is done can
> be seen on page 417 of the EJB-2.0-spec - I have used it and 
> it works (once
> you get the syntax right). So there is really no need to 
> create special
> Orion-specific lookups like P. Pontbriand has been doing - I tried P.
> Pontbriands solution, but could not make it work, which was 
> why I moved on
> to the <ejb-link>-solution.
> Still, to the best of my knowledge, it should only be 
> necessary to add the
> <ejb-link> if your beans reside in different jars - so, the 
> fact that Orion
> users need to add this tag even with beans residing in the 
> same jar is an
> error (I assume).
> 
> One happy developer - you made my day, Luke!
> Randahl Fink Isaksen
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Luke Nelson
> Sent: 18. januar 2001 21:46
> To: Orion-Interest
> Subject: RE: Getting the home interface of another EJB from within an
> EJB
> 
> 
> Have you tried putting an ejb-link reference in your 
> ejb-jar.xml?  Just an
> idea.
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Randahl Fink
> Isaksen
> Sent: Thursday, January 18, 2001 10:24 AM
> To: Orion-Interest
> Subject: RE: Getting the home interface of another EJB from within an
> EJB
> 
> 
> Thanks, Klaus - but the strange thing is, I have tried 
> carrying out the
> exact same lookup from within my JSP and within my EJB - for instance:
> 
> UserHome userHome = null;
> object = context.lookup("java:comp/env/ejb/UserHome");
> userHome = (UserHome) PortableRemoteObject.narrow(object, 
> UserHome.class);
> 
> It works in my JSPs but inside my EJBs it throws a 
> NameNotFoundException.
> 
> 
> Any ideas???
> 
> Randahl
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of
> [EMAIL PROTECTED]
> Sent: 18. januar 2001 11:49
> To: Orion-Interest
> Subject: SV: Getting the home interface of another EJB from within an
> EJB
> 
> 
> You work with EJBs inside another EJB the same way as you do 
> inside a JSP
> 
> Remember you have to use the JNDI name, not the home 
> interface name, so a
> lookup("ejbSomeExample") will ofcourse return the home interface :)
> 
> Hope this helps (ps remember ejb-refs to the objects you wish 
> to use from
> the bean you are calling from or it will not work..
> 
> Klaus
> 
> -----Opprinnelig melding-----
> Fra: Randahl Fink Isaksen [mailto:[EMAIL PROTECTED]]
> Sendt: 18. januar 2001 11:00
> Til: Orion-Interest
> Emne: Getting the home interface of another EJB from within an EJB
> 
> 
> >From inside an entity bean you can get hold of your Home interface by
> calling
> 
> myBeansEntityContext.getEJBHome()
> 
> but how do I get hold of the home interface of _another_ bean?
> 
> I assume this requires some kind of lookup. In JSP files one 
> would simply
> use "new InitialContext()" and perform a lookup on this 
> context, but if I do
> so within an EJB, I am not able to find any home interfaces 
> at all - I get a
> NameNotFoundException.
> 
> Now, is it really necessary to go all the way and get an 
> InitialContext by
> setting up environment properties and creating an 
> InitialContext from these
> plus adding an "application-client.xml" to the 
> deployment....?? - After all
> I am still inside an EJB...
> 
> 
> Any hints would be appreciated.
> 
> Randahl
> 
> 
> 
> 
> 
> 
> 
> 

Reply via email to