geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Siraj Mohamed" <Si...@virtusa.com>
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
com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:10
8)
            at
com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:11
6)
            at
javax.naming.InitialContext.lookup(InitialContext.java:361)
            at ejb.demo.DemoBean.ejbCreate(DemoBean.java:116)
 
My ejb-jar.xml contains following information.
 
enterprise-beans>
      <session id="Session_Demo">
         <description><![CDATA[The bean implementation class for the
Demo EJB.]]></description>
         <ejb-name>Demo</ejb-name>
         <home>ejb.demo.DemoHome</home>
         <remote>ejb.demo.Demo</remote>
         <ejb-class>ejb.demo.DemoBean</ejb-class>
         <session-type>Stateful</session-type>
         <transaction-type>Bean</transaction-type>
 
         <resource-ref id="ResRef_1">
            <res-ref-name>xmeta_defaultDS</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
            <res-sharing-scope>Shareable</res-sharing-scope>
         </resource-ref>
      </session>
 
      <session id="Session_Demo2">
         <description><![CDATA[The bean implementation class for the
Demo EJB.]]></description>
         <ejb-name>Demo2</ejb-name>
         <home>ejb.demo2.Demo2Home</home>
         <remote>ejb.demo2.Demo2</remote>
         <ejb-class>ejb.demo2.Demo2Bean</ejb-class>
         <session-type>Stateless</session-type>
         <transaction-type>Container</transaction-type>
      </session>
   </enterprise-beans>
 
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">
   .................
   <ejb-local-ref>
    <ejb-ref-name>ejb/Demo2</ejb-ref-name>
    <ejb-ref-type>Stateless</ejb-ref-type>
    <local-home>ejb.demo2.Demo2Home</local-home>
    <local>ejb.demo2.Demo2</local>
    <ejb-link>Demo2</ejb-link>
   </ejb-local-ref>
</session>
 
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,
Siraj
 
 
 

Mime
View raw message