2 Replies Latest reply on Feb 14, 2008 5:17 AM by Andrew Rubinger

    EJB Local Home in EJB 3.0

    Gupta Kancharla Newbie

      Hi,
      Is JBoss supports LocalHome? I am not able to lookup from the JSF backing bean which is also in the same ear file.

      I have created an Stateful Session Bean as follows

      @Stateful
      @LocalHome(value=TestUserHome.class)
      public class TestUserBean implements TestUserLocal {
      @Init
      public void initDefault(){

      }
      ...
      }

      My ear package is as follows.
      MyApplication.ear
      |
      |____ entities.jar
      |
      |____ ejb-beans.jar
      |
      |____ webapp.war
      |
      |____ META-INF
      |
      |____ application.xml


      I need to lookup the TestUserHome which is in ejb-beans.jar from my JSF backing bean which is webapp.war. I tried the following ways to lookup none of them successful.

      a) TestUserBean/localhome
      b) TestUserBean/home
      c) ejb-beans.jar#TestUserBean/home
      d) Define in web.xml as follows

      <ejb-local-ref>
      <ejb-ref-name>TestUser</ejb-ref-name>
      <ejb-ref-type>Session</ejb-ref-type>
      <local-home>com.test.TestUserHome</local-home>
      com.test.TestUserLocal
      </ejb-local-ref>

      and in jboss-web.xml
      <ejb-local-ref>
      <ejb-ref-name>TestUser</ejb-ref-name>
      <local-jndi-name>TestUserBean/localhome</local-jndi-name>
      </ejb-local-ref>

      e) TestUserHome.class.getName();


      Please suggest me how to lookup LocalHome. I am using jboss-4.2.2.GA

      Thank you,
      Gupta.

        • 1. Re: EJB Local Home in EJB 3.0
          Arbi Sookazian Master

          We are using Seam 2.0 with JBoss 4.2.1.GA. In EJB3 session beans, you only need a local interface and the SFSB/SLSB implementation class.

          There is no need for LocalHome interface with EJB3 as far as I know.

          example:

          @Stateful
          @Name("orderAction") //@Name is Seam specific annotation
          public class OrderAction implements OrderActionLocal
          {
          ...
          }
          
          @Local
          public interface OrderActionLocal
          {
          ...
          }


          Via JSF EL, we execute public methods that are defined in both the interface and class above:
          <h:commandButton id="update"
           value="Update"
           action="#{orderAction.updateOrder}" />


          The EJB3 expert group is planning on eliminated the local interface for session beans in the 3.1 spec. http://bill.burkecentral.com/category/ejb-31/ They have already been eliminated local and remote for entity beans (JPA entities) in EJB3.

          JSR220 - EJBCORE:

          section 3.6.3

          This was the only way of providing a local client view in EJB 2.1 and earlier releases. The local client view provided by the business interface in EJB 3.0 as described in Section 3.4 is now to be preferred.

          section 3.4

          The EJB 3.0 local or remote client of a session bean written to the EJB 3.0 API accesses a session bean through its business interface. The business interface of an EJB 3.0 session bean is an ordinary Java interface, regardless of whether local or remote access is provided for the bean.


          Hope that helps!

          • 2. Re: EJB Local Home in EJB 3.0
            Andrew Rubinger Master

            Yes, the EJB 3.0 specification supports 2.1 Views for interop / backwards-compat, and JBoss EJB3 implements this.

            Sounds like you're just not finding the Home in JNDI. Use the JNDI Viewer in the JMX Console:

            http://jboss.org/wiki/Wiki.jsp?page=DisplayTheJDNITreeWithTheJMXConsole

            If you don't see an object implementing LocalHome defined, we might have to take a look at how you're declaring your 2.1 View. Should just be:

            @Stateless
            @LocalHome(MyLocalHome.class)
            public class MyBean implements MyLocalInterface{...}

            public interface MyLocalHome extends EJBLocalHome{...}


            S,
            ALR