3 Replies Latest reply on Mar 9, 2004 2:16 AM by anamika

    Calling one EJB method from another ejb on remote server

    anamika Newbie

      hi all,

      i am trying call an ejb from another ejb. the two ejbs are in different servers. So I am calling a method from AEJB to BEJB. JBoss 3.0.4 is used. Here at AEJB, i have given like this.

      Properties props = new Properties();
      props.setProperty( "java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory" );
      props.setProperty( "java.naming.provider.url", "Remote Machine IP:1099" );
      props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");

      Context context = new InitialContext(props);

      BHome bHome=(BHome)javax.rmi.PortableRemoteObject.narrow(context.lookup("ejb/RemoteBean1"),BHome.class);
      BInterface bInterface = bHome.create();
      bInterface.method1 ();

      Here ejb/RemoteBean1 is the jndi name of the remote ejb and BHome is the the home and BInterface is the remote interface.

      At BeanA side, ejb-jar.xml-

      <ejb-name>AEJB</ejb-name>
      package.AHome
      package.AInterface
      <ejb-class>package.AEJB</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
      <ejb-ref>
      <ejb-ref-name>ejb/RemoteBean1</ejb-ref-name>
      <ejb-ref-type>Stateless</ejb-ref-type>
      package.BHome
      package.BInterface
      </ejb-ref>


      At Bean A side jboss.xml -

      <ejb-name>AEJB</ejb-name>
      <ejb-ref>
      <ejb-ref-name>ejb/RemoteBean1</ejb-ref-name>
      <jndi-name>jnp://Remote Server IP:1099/ejb/RemoteBean1</jndi-name>
      </ejb-ref>



      At Bean B side ejb-jar.xml

      <ejb-name>ejb/RemoteBean1</ejb-name>
      package.BHome
      package.BInterface
      <ejb-class>package.BEJB</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>


      Now I am getting remote exception. Pls help me. Both of in same port 1099. Home object is creating. But when remote interface is created by home.create(), it is showing remote eception. At both the servers, EJBs are bound and identifying it as remote EJB. Expecting a reply as early as possible. Thanks

      anamika