[omniORB] Java IDL / RMI-IIOP server and omniORBpy client -- not
working
Neeraj Mahajan
neeraj_mahajan at persistent.co.in
Fri Mar 24 18:52:18 GMT 2006
I am trying to develop a CORBA sever using Java IDL and client using
omniORBpy. I am using omniORB-4.1.0-beta1 and omniORBpy-3.0-beta1.
I believe this type of client-server setup should work as CORBA is meant for
interoperability. I am not able to run my example this way. I think I am
making some minor mistake.
I have taken the IDL file from the examples mentioned in omniORBpy doc PDF.
// echo_example.idl
module Example {
interface Echo {
string echoString(in string mesg);
};
};
Using Java idlj tool I generated the java wrappers. And then wrote
EchoServer.java as follows
//EchoServer.java
package Example;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POA;
import java.util.Properties;
class EchoPOAImpl extends EchoPOA {
private ORB orb;
public void setORB(ORB orb_val) {
orb = orb_val;
}
// implement sayHello() method
public String echoString (String in) {
System.out.println("Received from Client - " + in);
return "\nEcho - " + in + "\n";
}
}
public class EchoServer {
public static void main(String args[]) {
try{
// create and initialize the ORB
ORB orb = ORB.init(args, null);
// get reference to rootpoa & activate the POAManager
POA rootpoa =
POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
rootpoa.the_POAManager().activate();
// create servant and register it with the ORB
EchoPOAImpl helloImpl = new EchoPOAImpl();
helloImpl.setORB(orb);
// get object reference from the servant
org.omg.CORBA.Object ref = rootpoa.servant_to_reference(helloImpl);
Echo href = EchoHelper.narrow(ref);
// get the root naming context
org.omg.CORBA.Object objRef =
orb.resolve_initial_references("NameService");
// Use NamingContextExt which is part of the Interoperable
// Naming Service (INS) specification.
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
// bind the Object Reference in Naming
String name = "ExampleEcho.Object";
NameComponent path[] = ncRef.to_name( name );
for(int i=0;i<path.length;i++) {
System.out.println("NameComponent " + i + ": id = '" +
path[i].id + "' kind = '" + path[i].kind + "'");
}
ncRef.rebind(path, href);
System.out.println("EchoServer ready and waiting ...");
// wait for invocations from clients
orb.run();
}
catch (Exception e) {
System.err.println("ERROR: " + e);
e.printStackTrace(System.out);
}
System.out.println("EchoServer Exiting ...");
}
}
The python client code is same as mentioned in the omniORBpy.pdf (section
2.6.4 Client code)
Now I start the name service using Java's orbd - "start orbd
-ORBInitialPort 1052"
Start the Java server - "java -cp . Example.EchoServer -ORBInitialPort 1052"
Run the Python client. I get the following error:
Traceback (most recent call last):
File "C:\temp\omni\ex3\hello2.py", line 9, in ?
rootContext = obj._narrow(CosNaming.NamingContext)
File ".\CORBA.py", line 755, in _narrow
TRANSIENT: CORBA.TRANSIENT(omniORB.TRANSIENT_ConnectFailed,
CORBA.COMPLETED_NO)
My InitRef entry for omniORB is "NameService=corbaname:iiop:localhost:1052".
If I test the server with Java client or the Python client with Python
server then everything works fine.
What am I doing wrong here?
Could someone tell me which one of JavaIDL or Java RMI-IIOP is better for
the setup I am planning i.e. Java server and Python client.
Thanks,
Neeraj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20060324/c00b37be/attachment-0001.htm
More information about the omniORB-list
mailing list