[omniORB] "ServantAlreadyActive" exception.
David Riddoch
djr@uk.research.att.com
Tue, 4 Jul 2000 13:03:28 +0100 (BST)
On Tue, 4 Jul 2000, Ben Miller wrote:
> I'm just updating my project to use omniORB3 (instead of
> omniORB2.7.1). I have code like this:
>
> // Initialise the Object Request Broker.
> cout << "Initialising ORB..." << endl;
> orb = CORBA::ORB_init(argc, argv, 0);
> cout << "... ORB initialised." << endl;
>
> // Initialise the root portable object adapter.
> cout << "Initialising POA..." << endl;
> CORBA::Object_var temp_obj =
> orb->resolve_initial_references("RootPOA");
> PortableServer::POA_var poa = PortableServer::POA::_narrow(temp_obj);
> cout << "... POA initialised." << endl;
>
> // Create a new object implementation
> cout << "Creating the LongJob implementation..." << endl;
> LongJobImpl* impl = new LongJobImpl;
> LongJob_var obj_ref = impl->_this(); // Get object reference.
The servant is activated here, by implicit activation.
> // Register servant object with POA.
> PortableServer::ObjectId_var myImpl = poa->activate_object(impl);
>
> I try to run this code (as my persistent server) and the very last
> line throws a "ServantAlreadyActive" exception. What could I be doing
> wrong here?
The solution is to either omit the last line, or activate the object
before you call _this(). I prefer the latter, because it is clearer.
Cheers,
David