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

J

Jayaram

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top