1 Reply Latest reply on Oct 5, 2004 10:45 AM by p_nevilleuk

    Calling remote session bean from servlet on another server o

    p_nevilleuk

      Hi,
      I am trying to call a remote stateless session bean from another server within a servlet.

      In the servlet I have:

      Hashtable env = new Hashtable();
      env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.HttpNamingContextFactory" );
      env.put(Context.PROVIDER_URL, "http://borg:8080/invoker/JNDIFactory");
      env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");

      InitialContext ic = new InitialContext(env);
      Object objref = ic.lookup("java:comp/env/ejb/remoteTest");
      Object obj = PortableRemoteObject.narrow(objref, RemoteEJBTestHome.class);
      RemoteEJBTestHome testHome = (RemoteEJBTestHome)obj;
      testHome.create();


      I have deployed the ear to both servers and when I call the servlet on one, the jndi lookup is successful.
      However, the bean executes in the ejb container of the local server rather than the remote one. This can be verified by the number of instances in the JMX console.

      How can I get the bean to execute on the remote server instead?

      Thanks.
      Peter