1 Reply Latest reply on Dec 13, 2001 5:29 PM by Travis J. Close

    Calling an EJB from an EJB

    Travis J. Close Newbie

      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