6 Replies Latest reply on Apr 5, 2005 11:42 AM by Derrick Koon

    Calling remote EJB ended up calling the local EJB

    Derrick Koon Newbie

      We are migrating an application from Weblogic to JBoss. We have a problem in calling a remote EJB.

      The scenario is this: We have two JBoss servers on two machines. The application with EJB's is deployed on both machines. There is one part of the application that no matter which machine it is executed from, it has to call a method on the local EJB, and the same method on the remote EJB. Both EJB's are the same type, they are just deployed on two machines.

      The symptom: Instead of both local and remote EJB's each getting called once, the LOCAL EJB got called TWICE! The remote EJB never got called.

      Our code:

      In the JNDI code, for both local and remote EJB, the following code with url specified is used:

      Properties p = new Properties();
      p.put(Context.PROVIDER_URL, urlString);
      InitialContext objContext = new InitialContext(p);
      Context contxt = objContext.getInitialContext();
      EJBHome home = (EJBHome)PortableRemoteObject.narrow(contxt.lookup(lookupName), homeClass);

      We have also tried the following but the result is the same:

      InitialContext objContext = new InitialContext();
      Context contxt = objContext.getInitialContext();
      contxt.addToEnvionment(Context.PROVIDER_URL, urlString);
      EJBHome home = (EJBHome)PortableRemoteObject.narrow(contxt.lookup(lookupName), homeClass);


      Runtime debugging statements from InitialContext environment

      ###Printing InitialContext environment hashtable for local call:
      ###Map Key: java.naming.provider.url Map value: jnp://192.168.7.91:1099
      ###Map Key: java.naming.factory.initial Map value: org.jnp.interfaces.NamingContextFactory
      ###Map Key: java.naming.factory.url.pkgs Map value: org.jboss.naming:org.jnp.interfaces:org.jboss.naming:org.jnp.interfaces
      ###HomeClass : AdminMainAppHome



      ###Printing InitialContext environment hashtable for remote call:
      ###Map Key: java.naming.provider.url Map value: jnp://192.168.7.44:1099
      ###Map Key: java.naming.factory.initial Map value: org.jnp.interfaces.NamingContextFactory
      ###Map Key: java.naming.factory.url.pkgs Map value: org.jboss.naming:org.jnp.interfaces:org.jboss.naming:org.jnp.interfaces
      ###HomeClass : AdminMainAppHome

      As you can see, the InitialContext does have the respective urls, but it is only invoking the local EJB. We know that because we have debugging statements inside the EJB and the local one got called twice.

      Request for ideas:

      I have searched many of the EJB forum items, and I read Chapter 3 of JBoss 4.01 guide, but still I could not find a solution. JBoss is new to me. Could someone shed some light, as we encountered several issues recently and are now behind schedule? What am I missing? What have we done wrong?

      Thanks