geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Siraj Mohamed" <>
Subject How to do a local bean lookup
Date Wed, 19 Apr 2006 06:54:58 GMT
Hi All,
I want to do a local lookup of a session bean from another session bean.
This is what I am actually trying to do:
I have two session bean bundled them in the same EAR and in my first
bean's method; I do a local lookup of the 2nd bean. This is the code:
Context jndiCntx = new InitialContext();
Object objref = null;
Demo2Home home = null;
objref = jndiCntx.lookup("Demo2");
home = (Demo2Home)PortableRemoteObject.narrow(
           objref, Demo2Home.class);
Demo2 demo = home.create();
Now I am invoking the 1st bean's method from a standalone java (remote
client), but I am getting following errors:
javax.naming.NameNotFoundException: Demo2
            at ejb.demo.DemoBean.ejbCreate(
My ejb-jar.xml contains following information.
      <session id="Session_Demo">
         <description><![CDATA[The bean implementation class for the
Demo EJB.]]></description>
         <resource-ref id="ResRef_1">
      <session id="Session_Demo2">
         <description><![CDATA[The bean implementation class for the
Demo EJB.]]></description>
If I lookup the 2nd bean remotely, it works fine but it does not work
locally. There were some discussion in the forum regarding this and
suggest introducing 'ejb-local-ref' tag. I added following for the 1st
bean in the ejb-jar.xml.
<session id="Session_Demo">
After this change, I could not deploy the EAR and getting XML parsing
exception for ejb-jar.xml. Possibly I am doing some thing wrong here.
Appreciate if any one could suggest a solution.
Thanks & Regards,

View raw message