[omniORB] java client cannot resolve omni nameservice

Xiaowen Wang swangken@cfdlab.ae.utexas.edu
Sat, 24 Mar 2001 22:08:41 -0600 (CST)


Hi:
I tried to let the java client to resolve the echo object reference
from the omni nameservice. However, it seems the orb always failed to
resolve the NameService. The following the is client code:

import org.omg.CORBA.*;
import org.omg.CosNaming.*;
import java.util.*;

public class EchoClient {
    public static void main(String args[]) {
	try {
	    Properties prop = new Properties();
	    prop.setProperty("ORBInitRef","NameService=corbaname:localhost:2809");
	    ORB orb = ORB.init(args, prop);
	    org.omg.CORBA.Object obj = orb.resolve_initial_references("NameService");
	    NamingContext ctxt = NamingContextHelper.narrow(obj);
	    NameComponent[] path = {
		new NameComponent("test","my_context"),
		new NameComponent("Echo","Object")
		    };
	    Echo echo = EchoHelper.narrow(ctxt.resolve(path));
	    String to = "Client: hello";
	    System.out.println("I said: "+ to);
	    String back = echo.echoString(to);
	    System.out.println("He said: "+ back);
	} catch (Throwable e) {
	    System.err.println(e);
	    e.printStackTrace(System.err);
	}
    }
}

Thanks in advance
XW