[omniORB] How to recover from "A servant has been deleted tha t is still act ivated"

Mark Johnson mark.johnson@onfiber.com
Wed, 22 Aug 2001 14:50:06 -0500


Sorry I'm not sure if I can provide all these details since I'm not familiar
enough with the all the corba details. But I'll try:

ENV: 
	Solaris 2.8, CC, OmniORB3.0
ERROR:
	omniORB: ERROR -- A servant has been deleted that is still
activated.
      id: root<0>
	caught CORBA::SystemException.

CMD LINE: 
	/home/mjohnson/bin/echo -s -ORBInitRef
NameServices=corbaname::neutron

The error appears when I first startup the server. I successfully completed
the eg3_impl/eg3_clt examples, but I forgot to shut down the server
(eg3_impl) before moving on the the tie example. When I finished doing the
tie example I tried running it and this is when I first got the error.  I
then killed the old server and the new server as well, but I continued to
get the error.  I then killed omniNames and deleted all the logs from
/var/log/omniORB/ and restarted the name server: omniNames -start. But none
of this seemed to help.

I am doing the tie example, I have retyped it in by hand and made some
slight modifications just do get a better feel for the whole thing. I'm sure
I've made an error during my refactoring, but I need assistance finding what
I did wrong.

The exeception above is thrown by the call to 
	CORBA::Object_var obj = aOrb->resolve_initial_references(
NAMESERVICE );
in the function BindObjectToName()

Below is snippets of the server code:
----------------------------------------------------------------------------
---------------------------
#include <iostream>
#include "echo_server.h"
#include "idl/echo.h" 
#include "echo_i.h"
#include <string>

const char * NAMESERVICE 	= "NameService";
const char * ROOT 		= "RootPOA";
CORBA::Boolean BindObjectToName( CORBA::ORB_ptr aOrb
                                 , CORBA::Object_ptr aObjRef
                                 , std::string & aErrMsg )
{
   CosNaming::NamingContext_var 	rootContext; 
   try
   {	
      // this line here throws the servant error!
      //
      CORBA::Object_var obj = aOrb->resolve_initial_references( NAMESERVICE
);
	
      rootContext = CosNaming::NamingContext::_narrow( obj );
      if( CORBA::is_nil(rootContext) )
      {
         aErrMsg = "failed to narrow the root naming context.";
         return 0;	
      }
   }
	< ... snip... >
}

// this should really be generic, but I can't find out what type it is 
// suppose to be so for now I'm passing "Echo_i *"
//
//int Initialize( ..., Servant * aServant, ... )
//
int Initialize( CORBA::ORB_var & aOrb
                , Echo_i * aServant
                , std::string & aErrMsg ) 
{
   try
   {
      // obtain a reference to the root POA
	//
	CORBA::Object_var nameServer = aOrb->resolve_initial_references(
ROOT );
	PortableServer::POA_var poa  = PortableServer::POA::_narrow(
nameServer );
	POA_Echo_tie<Echo_i> echoTie( aServant );

	// activate the object, tell POA that this object is ready for
clients...
	//
	PortableServer::ObjectId_var echoId = poa->activate_object( &echoTie
);
		
	// obtain a reference to the object using a stringified IOR
	//
	CORBA::Object_var obj = echoTie._this();
	if( !BindObjectToName(aOrb, obj, aErrMsg) )
	{
		aErrMsg += "\nfailed to bind object to name.";		
		return 0;
	}

	// obtain a POA Manager and tell the POA to start accepting
requests...
	//
	PortableServer::POAManager_var pman = poa->the_POAManager();
	pman->activate();
   }

   <...snip...>
   return 1;
}
int server( int argc, char * argv[] )
{
   Echo_i * echo = new Echo_i( "server" );
   try
   {
	Echo_i * echo = new Echo_i( "server" );
	CORBA::ORB_var orb = CORBA::ORB_init( argc, argv, "omniORB3" );

	std::string errmsg;
	if( Initialize(orb, echo, errmsg) )
	{
		orb->run();
		orb->destroy();
	}
	std::cerr << errmsg << std::endl;
   }

   <...snip..>
   return 0;
}

> -----Original Message-----
> From: Duncan Grisby [mailto:dgrisby@uk.research.att.com]
> Sent: Wednesday, August 22, 2001 11:19 AM
> To: Mark Johnson
> Cc: OmniOrb Mailing List (E-mail)
> Subject: Re: [omniORB] How to recover from "A servant has been deleted
> that is still act ivated" 
> 
> 
> On Wednesday 22 August, Mark Johnson wrote:
> 
> > I'm new here, day 3 in corba/omniorb-ville.  I checked 
> through the archives
> > and found out that the reason I got this error, "A servant 
> has been deleted
> > that is still activated", is because I accidently ran the 
> "echo" example
> > server twice.
> 
> Precisely what happened?  Please explain what emitted the error, what
> version of omniORB you are using, and what your platform and compiler
> is.
> 
> It is no problem to start more than one echo server (I assume you mean
> eg3_impl). The most recently started one over-writes the name service
> entries for any earlier ones, exactly as it should. If you are seeing
> a failure in doing this, something somewhere is broken.
> 
> Cheers,
> 
> Duncan.
> 
> -- 
>  -- Duncan Grisby  \  Research Engineer  --
>   -- AT&T Laboratories Cambridge          --
>    -- http://www.uk.research.att.com/~dpg1 --
>