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

    A problem with LocalHome

    Bisser Peshev Newbie

      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?