Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Question on - java.rmi.Naming.lookup() (http://www.velocityreviews.com/forums/t131828-question-on-java-rmi-naming-lookup.html)

Jayaram 02-28-2004 11:39 AM

Question on - java.rmi.Naming.lookup()
 
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

Sudsy 02-28-2004 01:20 PM

Re: Question on - java.rmi.Naming.lookup()
 
Jayaram wrote:
<snip>

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

With this:
System.out.println("Registry contains - "+slist[i]);
Doh!



All times are GMT. The time now is 05:14 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.