AW: [omniORB] Beginner's question about corbaloc

fischer.c at atlas.de fischer.c at atlas.de
Fri Nov 12 11:06:41 GMT 2004


Hi Jörg,

besides the missing port number there is one more thing to note on your server's code.

After activating the servant by activate_object_with_id() you are calling
_this() to create an object reference.
This call is obsolete and may also lead to some strange side effects.
You should simply remove it, because the object references that it returns is not used at all and is not the one you expect.

To go into more detail, _this() activates your servant in the POA returned by the virtual ServantBase method _default_POA(). As long as you don't override this method, it will return the root POA. As a consequence calling _this() in the way you do ends up with your servant activated twice, once in omniINSPOA and once in the root POA.

Moreover the object reference returned by _this() is not identical to the one used by your client, because it actually created a different object.

If you need the object reference of the correct object somewhere in your server's code, i.e. for registration in a naming service, you should create it by the following call:

CORBA::Object_var obj = poa->id_to_reference(oid);

Best regards,
Clemens



-----Ursprüngliche Nachricht-----
Von: omniorb-list-bounces at omniorb-support.com [mailto:omniorb-list-bounces at omniorb-support.com] Im Auftrag von Jochen Behrens
Gesendet: Donnerstag, 11. November 2004 14:32
An: Jörg König
Cc: omniORB
Betreff: Re: [omniORB] Beginner's question about corbaloc

Hi Jörg,

the port information in the URI is missing. The correct form of the URI is:

corbaloc:iiop:<host>:<port>/<object key>  (see also section 6.1 of the 
omniORB User's Guide)

You should change your client implementation for example as follows:
...
CORBA::String_var strIOR =
CORBA::string_dup("corbaloc::localhost:*4711*/POAtest");
CORBA::Object_ptr obj = orb->string_to_object(strIOR);
...

and start the server with the corresponding endpoint parameter:

 > server -ORBendPoint giop:tcp::*4711*

Best Regards,
Jochen

Jörg König wrote:

> Hi,
>
> My name is Jörg. I'm new to this mailing list. My native language is
> german, so forgive me if my english isn't the best :)
>
> Now for the problem: Until now I used omniORB 2.8 for a very long time
> and thought it would be time to upgrade to a somewhat newer version. So
> far I used the BOA model in conjunction with a NameService for a set of
> Servers. Now I need to develop a server that can be contacted without
> the need of a NameService and thought the "corbaloc" could solve my 
> problem.
>
> I tried omniORB 4.0.5 and wrote a very simple server/client application
> to see how it works. The interface is as simple as the echo-sample that
> comes with omniORB. My server's main() looks like this (all error
> handling stripped off, because the debugger does the work, too :-) ):
>
> int main(int argc, char ** argv)
> {
>         CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
>         CORBA::Object_var obj = 
> orb->resolve_initial_references("omniINSPOA");
>         PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
>
>         poa->the_POAManager()->activate();
>
>         IEcho * echo = new IEcho();
>         PortableServer::ObjectId_var oid =
> PortableServer::string_to_ObjectId("POAtest");
>         PortableServer::ServantBase_var servant = echo;
>         poa->activate_object_with_id(oid, servant);
>
>         Echo_var v = echo->_this();
>         echo->_remove_ref();
>
>         cout << "Server is ready" << endl;
>         orb->run();
>
>         return 0;
> }
>
> The client side looks like this:
>
> int main(int argc, char ** argv) {
>         CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
>
>         CORBA::String_var strIOR =
> CORBA::string_dup("corbaloc::localhost:/POAtest");
>         CORBA::Object_ptr obj = orb->string_to_object(strIOR);
>         Echo_var v = Echo::_narrow(obj);  // this will throw an exception
>
>         cout << v->send("Hello Server") << endl;
>
>         orb->destroy();
>         return 0;
> }
>
> (I'm not giving any arguments (argc/argv) to either the server or 
> client.)
> Unfortunataly the client doesn't work as expected. As soon as I try to
> narrow the object to its real type, the ORB throws a TRANSIENT exception.
> I think I'm missing something, but cannot figure out what it is...
>
> Hope someone can enlighten me :)
>
>         Jörg
> -- 
> Mail:    J.Koenig at adg.de
> Company: ADG mbH, Mannheim Germany
> Phone:   +49 0621/8505-609
>
> _______________________________________________
> omniORB-list mailing list
> omniORB-list at omniorb-support.com
> http://www.omniorb-support.com/mailman/listinfo/omniorb-list
> - - - - - - - DISCLAIMER - - - - - - - -
> Unless indicated otherwise, the information contained in this message 
> is privileged and confidential, and is intended only for the use of 
> the addressee(s) named above and others who have been specifically 
> authorized to receive it. If you are not the intended recipient, you 
> are hereby notified that any dissemination, distribution or copying of 
> this message and/or attachments is strictly prohibited. The company 
> accepts no liability for any damage caused by any virus transmitted by 
> this email. Furthermore, the company does not warrant a proper and 
> complete transmission of this information, nor does it accept 
> liability for any delays. If you have received this message in error, 
> please contact the sender and delete the message. Thank you.
>

_______________________________________________
omniORB-list mailing list
omniORB-list at omniorb-support.com
http://www.omniorb-support.com/mailman/listinfo/omniorb-list





More information about the omniORB-list mailing list