[omniORB] using persistent reference with corbaloc

Wernke zur Borg wzb at anitesystems.de
Tue Mar 22 08:02:21 GMT 2005


Hi Frederico,

unfortunately you do not write how you try to resolve your URI. You can use
the URI just like an ordinary stringified IOR and call string_to_object() on
it.

For your very first test I suggest to use the predefined 'omniINSPOA' on the
server side instead of a self-made one. You can even use it as your root
POA, so the code becomes quite simple.

Here is the echo example from the manual in a corbaloc variant. The only
different lines on the server side are the following (error handling
excluded):

    // Get a reference to the omniINSPOA
    CORBA::Object_var obj = orb->resolve_initial_references("omniINSPOA");
    ...
    PortableServer::POA_var insPoa = PortableServer::POA::_narrow(obj);
    ...

    // Create unique object key for IOR and activate with id
    PortableServer::ObjectId_var echoOid =
        PortableServer::string_to_ObjectId( "TheEcho" ); // Example name
    insPoa->activate_object_with_id( echoOid, myecho );
    ...

    Start the server with option "-ORBendPoint giop:tcp::40001".


On the client side you have:
      
    // Convert stringified IOR to Object Reference
    const char* sior = argv[1];
    CORBA::Object_var obj = orb->string_to_object( sior );
    Echo_var echoref = Echo::_narrow( obj );
    ...

    Start the client with argument "corbaloc::localhost:40001/TheEcho"


Once this works you can try to make it more cumbersome... ;-)

Wernke 

> -----Original Message-----
> From: Frederico Faria [mailto:fred_faria at yahoo.com.br] 
> Sent: 21 March 2005 18:28
> To: Wernke zur Borg; omniorb-list at omniorb-support.com
> Cc: jay.welch at transcore.com
> Subject: RE: [omniORB] using persistent reference with corbaloc
> 
> Hi Borg and Welch,
> 
> Thank you for your help. I really was using the wrong
> option. Probably that was  the reason because my
> server IOR was being generated differently at each new
> run.
> 
> I have one more issue:  it seems that now the end
> point is being found  by client, but my corbaloc URI
> is not being resolved yet. Is my URI imcomplete ? do I
> need have poa name, module name, version in the
> corbaloc URI ?  Below I attached the trace.
> 
> "corbaloc:iiop:wood:40001/AuthFactory"
> 
> 
> Thank you one more time,
> 
> Frederico Faria
> 
> 
> 
> Client Trace
> ---------------------------------------------------
> 
> 749 4f50 0100 0000 0000 0049 0000 0000
> GIOP.......I....
> 0000 0002 0100 0000 0000 000b 4175 7468
> ............Auth
> 4661 6374 6f72 7900 0000 0006 5f69 735f
> Factory....._is_
> 6100 6f6e 0000 0000 0000 0019 4944 4c3a
> a.on........IDL:
> 5449 4e43 2f41 7574 6846 6163 746f 7279
> TINC/AuthFactory
> 3a31 2e30 00                            :1.0.
> omniORB: inputMessage: from
> giop:tcp:10.131.10.150:40001 76 bytes
> omniORB:
> 4749 4f50 0100 0001 0000 0040 0000 0000
> GIOP....... at ....
> 0000 0002 0000 0002 0000 0027 4944 4c3a
> ...........'IDL:
> 6f6d 672e 6f72 672f 434f 5242 412f 4f42
> omg.org/CORBA/OB
> 4a45 4354 5f4e 4f54 5f45 5849 5354 3a31
> JECT_NOT_EXIST:1
> 2e30 0014 4f4d 0001 0000 0001           .0..OM......
> omniORB: throw OBJECT_NOT_EXIST from GIOP_C.cc:244
> (NO,OBJECT_NOT_EXIST_NoMatch)
> omniORB: throw OBJECT_NOT_EXIST from omniObjRef.cc:780
> (NO,OBJECT_NOT_EXIST_NoMatch)
> Caught a CORBA::SystemException.
> 
> 
> 
> 
> 
> -----------------------------------------------------
> Server Trace:
> 
> niORB: AsyncInvoker: thread id = 3 has started. Total
> threads = 3
> omniORB: giopWorker task execute.
> omniORB: Accepted connection from
> giop:tcp:10.131.10.150:38361 because of this rule: "*
> unix,ssl,tcp"
> omniORB: inputMessage: from
> giop:tcp:10.131.10.150:38361 85 bytes
> omniORB:
> 4749 4f50 0100 0000 0000 0049 0000 0000
> GIOP.......I....
> 0000 0002 0100 0000 0000 000b 4175 7468
> ............Auth
> 4661 6374 6f72 7900 0000 0006 5f69 735f
> Factory....._is_
> 6100 6f6e 0000 0000 0000 0019 4944 4c3a
> a.on........IDL:
> 5449 4e43 2f41 7574 6846 6163 746f 7279
> TINC/AuthFactory
> 3a31 2e30 00                            :1.0.
> omniORB: throw OBJECT_NOT_EXIST from GIOP_S.cc:331
> (NO,OBJECT_NOT_EXIST_NoMatch)
> omniORB: sendChunk: to giop:tcp:10.131.10.150:38361 76
> bytes
> omniORB:
> 
> 
> --- Wernke zur Borg <wzb at anitesystems.de> escreveu: 
> >  
> > Sorry I mistyped the argument.
> > 
> > Refer to Chapter 4 in the manual.
> > 
> > Your command line should read:
> > 
> > 	./server -ORBendPoint giop:tcp::40001
> > 
> > Alternatively you can set an environment variable:
> > 
> > 	export ORBendPoint=giop:tcp::40001
> > 
> > 
> > I mixed the two up, it's a bit confusing.
> > 
> > Wernke
> > 
> > > -----Original Message-----
> > > From: Frederico Faria
> > [mailto:fred_faria at yahoo.com.br] 
> > > Sent: 21 March 2005 16:25
> > > To: Wernke zur Borg;
> > omniorb-list at omniorb-support.com
> > > Subject: RE: [omniORB] using persistent reference
> > with corbaloc
> > > 
> > > Hi Borg,
> > > 
> > > This option doesn´t work for me ( see below ). I
> > also
> > > tried to use "-endPoint=giop:tcp::40001" but it
> > also
> > > didn´t work.  Below is the server code.
> > > Thank you,
> > > 
> > > Frederico Faria
> > > 
> > > ./server -ORBendPoint=giop:tcp::40001
> > -ORBtraceLevel
> > > 40
> > > omniORB: Configuration file "/etc/omniORB.cfg"
> > either
> > > does not exist or is not a file. No settings read.
> > > omniORB: ORB_init failed: unknown option
> > > (-ORBendPoint=giop:tcp::40001) in -ORB arguments
> > > Caught CORBA::SystemException.
> > > omniORB: Final clean-up
> > > omniORB: Released 254 static TypeCodes.
> > > omniORB: Deleted 0 nil object references and 2
> > other
> > > tracked objects.
> > > omniORB: Final clean-up completed.
> > >
> >
> -----------------------------------------------------
> > > 
> > > My server code is:
> > > 
> > >  CORBA::Object_var obj =
> > > orb->resolve_initial_references("RootPOA");
> > >     PortableServer::POA_var root_poa =
> > > PortableServer::POA::_narrow(obj);
> > >     PortableServer::POAManager_var pman =
> > > root_poa->the_POAManager();
> > >     pman->activate();
> > > 
> > >     // Create a new POA with the persistent
> > lifespan
> > > policy.
> > >     CORBA::PolicyList pl;
> > >     pl.length(2);
> > >     pl[0] =
> > >
> >
> root_poa->create_lifespan_policy(PortableServer::PERSISTENT);
> > >     pl[1] =
> > >
> >
> root_poa->create_id_assignment_policy(PortableServer::USER_ID);
> > > 
> > >     PortableServer::POA_var poa =
> > > root_poa->create_POA("my poa", pman, pl);
> > > 
> > >     // Always use the same object id.
> > >     PortableServer::ObjectId_var oid =
> > >      
> > > PortableServer::string_to_ObjectId("AuthFactory");
> > > 
> > >     // Activate the echo object...
> > >     TINC_AuthFactory_i* myauth = new
> > > TINC_AuthFactory_i();
> > >     poa->activate_object_with_id(oid, myauth);
> > > 
> > >     obj = myauth->_this();
> > >     CORBA::String_var
> > > sior(orb->object_to_string(obj));
> > >     cerr << "'" << (char*)sior << "'" << endl;
> > > 
> > >     myauth->_remove_ref();
> > > 
> > >     orb->run();
> > > 
> > > 
> > > 
> > > 
> > > 
> > > --- Wernke zur Borg <wzb at anitesystems.de> wrote:
> > > > 
> > > > Try calling
> > > > 
> > > > 	./server -ORBendPoint=giop:tcp::40001
> > > > 
> > > > instead of
> > > > 
> > > > 	./server -endPoint=giop:tcp:wood:40001
> > > > 
> > > > 
> > > > Furthermore, are you using the special
> > omniINSPOA,
> > > > and are you activating
> > > > your object(s) with activate_object_with_id() ?
> > > > 
> > > > Wernke 
> > > > 
> > > > > -----Original Message-----
> > > > > From: omniorb-list-bounces at omniorb-support.com
> > 
> > > > >
> > [mailto:omniorb-list-bounces at omniorb-support.com]
> > > > On Behalf 
> > > > > Of Frederico Faria
> > > > > Sent: 21 March 2005 14:46
> > > > > To: omniorb-list at omniorb-support.com
> > > > > Subject: [omniORB] using persistent reference
> > with
> > > > corbaloc
> > > > > 
> > > > > Hi all,
> > > > > 
> > > > >  I am using the omni example ( available in
> > > > product
> > > > > distribution ) for persistent object
> > reference.
> > > > > 
> > > > > But in my client code when I use the IOR
> > dumped
> > > > from
> > > > > server everything works fine. 
> > > > > But  when I try to use the corbaloc syntax the
> > > > things
> > > > > dont´work. I would like to use the corbaloc
> > syntax
> > > > > on client instead the IOR.
> > > > > 
> > > > >  My client piece of code with corbaloc:
> > > > >    
> > > > >    CORBA::String_var strIOR =
> > > > > ("corbaloc:iiop:wood:40001/AuthFactory");
> > > > >    CORBA::Object_ptr obj =
> > > > > ob->string_to_object(strIOR);
> > > > > 
> > > > >  
> > > > >    The server code ( copied from omni example
> > > > > directory ) uses the "AuthFactory" as object
> > id.
> > > > > I start the server like: 
> > > > >  ./server -endPoint=giop:tcp:wood:40001
> > > > > 
> > > > > Both server and client are running at same
> > host.  
> > > > > When I run the client I receive a CORBA
> > exception.
> > > > > Below are the server and client trace. 
> > > > > Could Somebody give any help to resolve the
> > > > problem.
> > > > > 
> > > > > Thank you,
> > > > > Frederico Faria
> > > > > 
> > > > > 
> > > > > -------------------------------------------
> > > > >  Server Trace
> > > > > omniORB: Initialising incoming endpoints.
> > > > > omniORB: Bind to address 0.0.0.0.
> > > > > omniORB: Starting serving incoming endpoints.
> > > > > omniORB: AsyncInvoker: thread id = 1 has
> > started.
> > > > > Total threads = 1
> > > > > omniORB: giopRendezvouser task execute for
> > > > > giop:tcp:10.131.10.150:38191
> > > > > omniORB: Adding root/my poa<AuthFactory>
> > > > (activating)
> > > > > to object table.
> > > > > omniORB: State root/my poa<AuthFactory>
> > > > (activating)
> > > > > -> active
> > > > > omniORB: Creating ref to local: root/my
> > > > > poa<AuthFactory>
> > > > >  target id      : IDL:TINC/AuthFactory:1.0
> > > > >  most derived id: IDL:TINC/AuthFactory:1.0
> > > > > 
> > > > > 
> > > > >
> > 
> === message truncated === 
> 
> 
> 	
> 	
> 		
> Yahoo! Mail - Com 250MB de espaço. Abra sua conta! 
> http://mail.yahoo.com.br/
> 




More information about the omniORB-list mailing list