I'm doing a practice of Distributed Systems subject of my University. We have to do an application which shows the current hour using CORBA where the server is written one language and client written in other.
I decided to use Python for server and Java for client. And I'm using omniORB for compiling for Python the IDL file.
from datetime import *import sys, osimport CORBA, CosNaming, Util, Util__POAclass Hora_i(Util__POA.Hora): def get_hora(self): return datetime.today()orb = CORBA.ORB_init(sys.argv)poa = orb.resolve_initial_references("RootPOA")poa._get_the_POAManager().activate()servant = Hora_i()poa.activate_object(servant)servantObjref = servant._this()print orb.object_to_string(servant._this())#horaObjref = servant._this()nameRoot = orb.resolve_initial_references("NameService")nameRoot = nameRoot._narrow(CosNaming.NamingContext)try: if nameRoot is None: print "NameService narrow failed" sys.exit(1)except CORBA.ORB.InvalidName, ex: # This should never happen, since "NameService" is always a # valid name, even if it hadn't been configured. print "Got an InvalidName exception when resolving NameService!" sys.exit(1)except CORBA.NO_RESOURCES, ex: print "No NameService configured!" sys.exit(1)except CORBA.SystemException, ex: print "System exception trying to resolve and narrow NameService!" print ex sys.exit(1)try: name = [CosNaming.NameComponent("hora", "")] horaContext = nameRoot.bind_new_context(name)except CosNaming.NamingContext.AlreadyBound, ex: # There is already a context named "hora", so we resolve # that. print 'Reusing "hora" naming context.' horaContext = nameRoot.resolve(name) horaContext = horaContext._narrow(CosNaming.NamingContext) if horaContext is None: # Oh dear -- the thing called "hora" isn't a # NamingContext. We could replace it, but it's safer to # bail out. print 'The name "hora" is already bound in the NameService.' sys.exit(1)horaContext.rebind([CosNaming.NameComponent("DarHora","")], servantObjref)print "DarHora bound in NameService. "orb.run()Actually I can compile and run the server side without problems. (I think that)
On the other hand, this is my java code
import Util.*;import org.omg.CORBA.*;import org.omg.CosNaming.*; public class Cliente { public static void main(String args[]) { try{ ORB orb = ORB.init(args,null); // obtener una referencia a NameService org.omg.CORBA.Object objRef = orb.resolve_initial_references("DarHora"); // las siguientes lineas nos permiten obtener una ref a un objeto remoto NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); // nombre del obj remoto String nombre = "DarHora"; Hora impl = HoraHelper.narrow(ncRef.resolve_str(nombre)); System.out.println(impl.get_hora()); } catch (Exception e) { System.out.println("ERROR : "+ e); e.printStackTrace(System.out); } }}In java I compile my file but when I try to run it there's an error. This is my stacktrace
com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl <init>WARNING: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: 127.0.1.1; port: 900"org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2200) at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2221) at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:223) at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:236) at com.sun.corba.se.impl.transport.SocketOrChannelContactInfoImpl.createConnection(SocketOrChannelContactInfoImpl.java:119) at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(CorbaClientRequestDispatcherImpl.java:185) at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.request(CorbaClientDelegateImpl.java:136) at com.sun.corba.se.impl.resolver.BootstrapResolverImpl.invoke(BootstrapResolverImpl.java:99) at com.sun.corba.se.impl.resolver.BootstrapResolverImpl.resolve(BootstrapResolverImpl.java:132) at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(CompositeResolverImpl.java:47) at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(CompositeResolverImpl.java:47) at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(CompositeResolverImpl.java:47) at com.sun.corba.se.impl.orb.ORBImpl.resolve_initial_references(ORBImpl.java:1169) at Cliente.main(Cliente.java:10)Caused by: java.net.ConnectException: Connection refused at sun.nio.ch.Net.connect0(Native Method) at sun.nio.ch.Net.connect(Net.java:465) at sun.nio.ch.Net.connect(Net.java:457) at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:639) at java.nio.channels.SocketChannel.open(SocketChannel.java:184) at com.sun.corba.se.impl.transport.DefaultSocketFactoryImpl.createSocket(DefaultSocketFactoryImpl.java:78) at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:206) ... 11 moreHow can I solve? Please, help me