2 Replies Latest reply on Apr 14, 2002 11:47 PM by Abe

    how to look up localbean??

    cs Newbie

      hi ,
      iam looking a localhome of an entitybean from a session bean.
      1)how can i lookup a localhome from a session bean.
      2)how should my ejb-jar.xml and jboss.xml should be.

      thanx in advance

        • 1. Re: how to look up localbean??
          Abe Newbie

          Hi,

          I got a similar thing happening with JBoss2.4.4.

          You may want to look at: http://main.jboss.org/thread.jsp?forum=47&thread=1941&message=120004&q=local+interfaces+jndi#120004

          Within your session bean, you will need to add something along the lines of...

          Context initial = new InitialContext();
          EntityLocalHome = (EntityLocalHome) initial.lookup("java:/comp/env/MyLocalEntity");

          and within your ejb-jar.xml file, add something like...

          <ejb-jar>
          <enterprise-beans>

          <ejb-name>MySessionBean</ejb-name>
          com.mysite.sessionbean.SessHome
          com.mysite.sessionbean.SessMgr
          <ejb-class>com.mysite.sessionbean.SessBean</ejb-class>
          <session-type>Stateless</session-type>
          <transaction-type>Container</transaction-type>
          <ejb-local-ref>
          <ejb-ref-name>MyLocalEntity</ejb-ref-name>
          <ejb-ref-type>Entity</ejb-ref-type>
          <ejb-link>MyEntityBean</ejb-link>
          <local-home>com.mysite.entitybean.EntityLocalHome</local-home>
          com.mysite.entitybean.EntityLocal
          </ejb-local-ref>


          <ejb-name>MyEntityBean</ejb-name>
          com.mysite.entitybean.EntityHome
          com.mysite.entitybean.Entity
          <local-home>com.mysite.entitybean.EntityLocalHome</local-home>
          com.mysite.entitybean.EntityLocal
          <ejb-class>com.mysite.entitybean.EntityBean</ejb-class>
          <persistence-type>Bean</persistence-type>
          <prim-key-class>java.lang.String</prim-key-class>
          False
          <resource-ref>
          <res-ref-name>MyDBPool</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
          <res-auth>Container</res-auth>
          </resource-ref>

          <assembly-descriptor>
          <container-transaction>

          <ejb-name>MyEntityBean</ejb-name>
          <method-intf>Remote</method-intf>
          <method-name>*</method-name>

          <trans-attribute>Required</trans-attribute>
          </container-transaction>
          </assembly-descriptor>
          </enterprise-beans>
          </ejb-jar>

          And of course you must create two new Local interfaces for your Entity Bean which should extend from javax.ejb.EJBLocalObject and javax.ejb.EJBLocalHome respectively.

          You can see some basic examples of Local interfaces etc from Ed Roman's book at http://www.theserverside.com. As someone else said on another thread here... just follow those examples and voila!

          Chrs,
          Abe