Question on - java.rmi.Naming.lookup()

Discussion in 'Java' started by Jayaram, Feb 28, 2004.

  1. Jayaram

    Jayaram Guest

    I have a server program that registers two remote objects with the
    rmiregistry. The Server code is as follows:

    ********************************************************************************
    import java.rmi.Naming;

    public class Server {
    public Server() {
    try{
    Service1 s1 = new StoreService();
    Naming.rebind("//172.25.14.65:1099/StoreService",s1);
    Service2 s2 = new RetrieveService();
    Naming.rebind("//172.25.14.65:1099/RetrieveService",s2);
    System.out.println("Registered Services with the registry");
    }catch(Exception e) {
    System.out.println("Exception in Server initialization "+e);
    e.printStackTrace();
    }
    }

    public static void main(String[] args) {
    new Server();
    }
    }
    ********************************************************************************

    I have a Client program that performs a lookup on the registry:

    public class Client{
    public static void main(String[] args) {
    try{
    String slist[] = Naming.list("//172.25.14.65:1099");
    int length = slist.length;
    for(int i=0;i<length;i++) {
    System.out.println("Registry contains - "+slist[0]);
    }
    }catch(Exception e) {
    System.out.println("Exception in Client "+e);
    e.printStackTrace();
    }
    }
    }

    Ideally the client should have seen entries for both the remote
    objects. But the client consistently prints:

    Registry contains - //172.25.14.65:1099/StoreService
    Registry contains - //172.25.14.65:1099/StoreService

    Why dont I see the entry:
    Registry contains - //172.25.14.65:1099/RetrieveService ?

    Regards,
    Jayaram
     
    Jayaram, Feb 28, 2004
    #1
    1. Advertising

  2. Jayaram

    Sudsy Guest

    Jayaram wrote:
    <snip>

    Replace:
    > System.out.println("Registry contains - "+slist[0]);

    With this:
    System.out.println("Registry contains - "+slist);
    Doh!
     
    Sudsy, Feb 28, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. F C
    Replies:
    0
    Views:
    2,233
  2. =?ISO-8859-1?Q?Richard_K=F6rber?=

    [RMI] Naming.lookup freezes

    =?ISO-8859-1?Q?Richard_K=F6rber?=, Jun 30, 2004, in forum: Java
    Replies:
    0
    Views:
    1,086
    =?ISO-8859-1?Q?Richard_K=F6rber?=
    Jun 30, 2004
  3. Jan Schulze
    Replies:
    1
    Views:
    571
    Esmond Pitt
    Mar 26, 2005
  4. Shin
    Replies:
    3
    Views:
    6,218
    E.J. Pitt
    Aug 27, 2005
  5. Harman
    Replies:
    1
    Views:
    2,511
    Moiristo
    Jul 28, 2006
Loading...

Share This Page