3 Replies Latest reply on May 10, 2006 12:55 PM by bdecoste

    A problem with LocalHome

    vesuvius

      Hi guys,

      I have a problem with EJB3 deployment.

      Because we use a framework that performs EJB2.1-style calls, I have to specify a LocalHome interface for my stateless EJB3 bean. I made a small EJB to test how to do this. Here's the EJB:

      @Stateless(name="Calculator")
      @Local(CalculatorLocal.class)
      @LocalHome(CalculatorLocalHome.class)
      @LocalBinding(jndiBinding="ejb/local/Calculator")
      
      public class CalculatorBean implements CalculatorLocal {
       int val = 0;
      
       public int plus(int num) {
       return num + val;
       }
      
       @Init
       public void ejbCreate() throws CreateException {
       this.val = 5;
       }
      
       @Remove
       public void ejbRemove(Object arg) throws RemoveException, EJBException {
       this.val = 0;
       }
      }


      Here's CalculatorLocal:

      @Local
      public interface CalculatorLocal {
       public int plus(int num);
      }


      Here's CalculatorLocalHome:

      public interface CalculatorLocalHome extends EJBLocalHome
      {
       public abstract Object create() throws CreateException;
      }


      Then, in the WAR file, I put the following in web.xml:
      ...
       <ejb-local-ref>
       <ejb-ref-name>ejb/local/Calculator</ejb-ref-name>
       <ejb-ref-type>Session</ejb-ref-type>
       <local-home>test.CalculatorLocalHome</local-home>
       <local>test.CalculatorLocal</local>
       <ejb-link>TestEJB.jar#Calculator</ejb-link>
       </ejb-local-ref>


      (TestEJB.jar is the jar file that contains the above class and interfaces)

      And then I buld an EAR file and I try to deploy it to JBoss 4.0.4 CR2. And JBoss throws the following error during deployment:

      org.jboss.deployment.DeploymentException: Error during deploy; - nested throwable: (javax.naming.NamingException: ejb-local-ref: 'ejb/local/Calculator', with web.xml ejb-link: 'TestEJB.jar#Calculator' failed to resolve to an ejb with a LocalHome)

      I know I'm doing something wrong but I don't know what. Any ideas?

        • 1. Re: A problem with LocalHome
          vesuvius

          Here's an excerpt from JBoss's Global JNDI Namespace:

          +- ejb (class: org.jnp.interfaces.NamingContext)
          | +- local (class: org.jnp.interfaces.NamingContext)
          | | +- CalculatorHome (proxy: $Proxy134 implements interface test.CalculatorLocalHome)
          | | +- Calculator (proxy: $Proxy133 implements interface test.CalculatorLocal,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)


          Hope it helps.

          • 2. Re: A problem with LocalHome
            bdecoste

            I've opened a JIRA task for this issue.

            http://jira.jboss.com/jira/browse/EJBTHREE-554

            • 3. Re: A problem with LocalHome
              bdecoste

              Configure the web deployment descriptors this way:

              web.xml

              <ejb-local-ref>
               <ejb-ref-name>ejb/local/Session30</ejb-ref-name>
               <ejb-ref-type>Session</ejb-ref-type>
               <local-home>org.jboss.ejb3.test.servlet.Session30LocalHome</local-home>
               <local>org.jboss.ejb3.test.servlet.Session30</local>
               </ejb-local-ref>
              


              jboss-web.xml
              <ejb-local-ref>
               <ejb-ref-name>ejb/local/Session30</ejb-ref-name>
               <local-jndi-name>Session30LocalHome</local-jndi-name>
               </ejb-local-ref>