[omniORB] ServantActivator problems

Stefan Seefeld seefelds@MAGELLAN.UMontreal.CA
Mon, 31 Jul 2000 01:48:56 -0400


hi,

I'm trying to run the following code but I get a runtime error 
and a CORBA::Exception in the call to poa->set_servant_manager.
What am I doing wrong ?

--------------------------------------------------------------
#include <iostream>
#include <omniORB3/CORBA.h>

class Activator : public virtual POA_PortableServer::ServantActivator
{
public:
  Activator() {}
  virtual ~Activator() {}
  virtual PortableServer::Servant incarnate(const PortableServer::ObjectId &oid,
					    PortableServer::POA_ptr poa)
    throw (CORBA::SystemException, PortableServer::ForwardRequest)
  {
    return 0;
  }
  virtual void etherealize(const PortableServer::ObjectId &oid,
			   PortableServer::POA_ptr poa,
			   PortableServer::Servant servant,
			   CORBA::Boolean, CORBA::Boolean)
    throw (CORBA::SystemException)
  {
    servant->_remove_ref();;
  }
};

int main(int argc, char **argv)
{
  try
    {

      CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB3");

      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 an activator servant
      Activator activator;
      PortableServer::ServantManager_var manager = activator._this();
      root_poa->set_servant_manager(manager);

      orb->run();
      orb->destroy();
    }
  catch(CORBA::SystemException&)
    {
      cerr << "Caught CORBA::SystemException." << endl;
    }
  catch(CORBA::Exception&)
    {
      cerr << "Caught CORBA::Exception." << endl;
    }
  catch(omniORB::fatalException& fe)
    {
      cerr << "Caught omniORB::fatalException:" << endl;
      cerr << "  file: " << fe.file() << endl;
      cerr << "  line: " << fe.line() << endl;
      cerr << "  mesg: " << fe.errmsg() << endl;
    }
  catch(...)
    {
      cerr << "Caught unknown exception." << endl;
    }
  return 0;
}

--------------------------------------------------------------

the program produces the following output:

omniORB: ERROR -- A servant has been deleted that is still activated.
 repo id: 
      id: root<0>
Caught CORBA::Exception.

Any help is highly appreciated !

Regards,	Stefan

_______________________________________________________              
              
Stefan Seefeld
Departement de Physique
Universite de Montreal
email: seefelds@magellan.umontreal.ca

_______________________________________________________

      ...ich hab' noch einen Koffer in Berlin...