1 Reply Latest reply on Aug 17, 2002 6:58 PM by Min gao

    call ejb from another ejb

    Min gao Newbie

      hello everyone:

      I dont know what shall I do calling one ejb from another one.

      I have two apps builded by tomcat in different port.both of ejbs using SessionbBean access EntityBean and than to database.

      My idea is using one ejb call the other ejb and responds the request.

      I have some clues that is for the client side, using jsp forum, for example, passing the parameter to Stateful SessionBean and call the server side SessionBean and go server side entitybean and then database, after obtain the data from DB, go back to the client sessinbean via the coming route, showing the result by a new jsp page.

      It sounds good, however, I have no idea about the client side. How do I use the sessionbean catch the data transfered from server side and shows to browser?


        • 1. Re: call ejb from another ejb
          Min gao Newbie

          this is my code using one SessionBean on client call another SessionBean on server.

          public class StaffManagementABean implements SessionBean {

          private StaffManagementBHome staffManagementBHome = null;

          private StaffManagementBHome getStaffManagementBHome() throws NamingException {
          //looking up branchB's sessionbean home
          Properties prop = new Properties();
          prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
          prop.put(Context.PROVIDER_URL, "localhost:1090");

          Context initial = new InitialContext();
          return (StaffMangementBHome) initial.lookup("StaffManagementB");

          public void ejbCreate() throws CreateException {
          try {
          staffManagementBHome = getStaffManagementBHome();
          } catch (Exception e) {
          }//end catch
          }//end ejbCreat

          public void ejbActivate() {
          try {
          staffManagementBHome = getStaffManagementBHome();
          } catch (NamingException e) {
          }//end catch
          }//end ejbActive

          public void ejbPassivate() {
          staffManagementBHome = null;
          public void ejbRemove() {}
          public void setSessionContext(SessionContext sc) {}

          The StaffManagementB in server side container, and when I compiling, obviously, give me folowing error,
          cannot resolve symbol class StaffManagementBHome