0 Replies Latest reply on Sep 6, 2006 3:32 PM by zhao liang

    How to: Ejb call Ejb from different machine

    zhao liang Newbie

      I have a sessionless ejb to call another sessionless ejb. When the two ejb are deployed in the same machine (jboss 4.0.4.GA), the call are fine, but , after I deploy in two different machine, I can't call it any more. The IP address of, is where the 2nd Ejb deployed

      The way I call another ejb from one ejb is as follow:
      //look up jndi in payment server machine
      Hashtable<String,String> env = new Hashtable<String,String>();
      env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory" );
      env.put(Context.PROVIDER_URL, "jnp://");
      env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces" );

      Context ctx = new InitialContext(env);

      //Object obj = ctx.lookup("java:/comp/env/ejb/PaymentEJB");
      Object obj = ctx.lookup("ejb/PaymentEJB");
      PaymentHome home = (PaymentHome)javax.rmi.PortableRemoteObject.narrow(obj,PaymentHome.class);
      Payment payment = home.create();
      resp = (HashMap<String,String>)payment.deposit(req);