EJB programming & troubleshooting: how to lookup a remote host jndi service

  1. how to lookup a remote host jndi service (2 messages)

    Can i lookup a ejb HOME INTERFACE in remote host using JNDI?
    please help me,thanks .
  2. how to lookup a remote host jndi service[ Go to top ]

       * Gets the home reference for an EJB associated
       * with the JNDI_Lookup_Name.
    private Object lookupHome(String jndiName,
             String initialContextFactory,
             String providerURL) throws NamingException {
    Properties env = new Properties();
    env.put (Context.INITIAL_CONTEXT_FACTORY,
    env.put(Context.PROVIDER_URL, providerURL);
    Context ctx = new InitialContext(env);
    return ctx.lookup(jndiName);

    you can use "weblogic.jndi.WLInitialContextFactory" for the initialContextFactory, "t3://" for providerURL if you are using weblogic. jndiName is whatever name the object is bound to on the server.

    make sure you cast the object returned from the above method to the proper home interface
  3. how to lookup a remote host jndi service[ Go to top ]

    thank Amar. I had do it like you said, but when i lookup HOME INTERFACE, i got a NULL result.

    *********************** my code ********************
    String url = "rmi://";
    Context initCtx = null;
    HelloHome hellohome = null;
    Hashtable env = new Hashtable();
    env.put(Context.PROVIDER_URL, url);
    initCtx = new InitialContext(env);
    dfad }catch(Exception e){
    System.out.println("Cannot get initial context: " + e.getMessage());
    hellohome = (HelloHome)initCtx.lookup("HelloHome");

    // *****hellohome==null**********
    Hello hello = hellohome.create();
    String s = hello.getHello();
    }catch(Exception e){