1 Reply Latest reply on Dec 13, 2001 5:29 PM by tclose

    Calling an EJB from an EJB

    tclose

      I have a stateless session EJB that needs to use another stateless session EJB.

      Within one of the methods of my first EJB, I try using the same code I use when accessing my 2nd EJB from a regular client. The code is as follows:

      InitialContext jndiContext = new InitialContext();
      Object ref = jndiContext.lookup("mybean/MyBean");
      MyBeanHome home = (MyBeanHome)PortableRemoteObject.narrow(ref, MyBeanHome.class);
      MyBean mybean = home.create();
      System.out.println(mybean.myMethod());

      It doesn't make it past the 2nd line (jndiContext.lookup), giving me this exeption:

      javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: com.mypackage.mybean.MyBeanHome]

      This code works fine in my client application. Any ideas on how to get it to work within my other EJB?

      -Travis

        • 1. Re: Calling an EJB from an EJB
          tclose

          OK. I am the person who submitted this rediculous question, and have since found the solution.

          I had my <ejb-ref> in my jboss-web and the correct entries in my web.xml, but I didn't copy my Home and Remote interfaces into the jar of my other EJB. Once I did that, everything worked. Now I feel stupid.