vishy_85 0 Newbie Poster

Im trying to create a c++ server. Im using the schedule_Mgmt IDL , where module-schedule_Mgmt and i hav 3 interfaces , 1-config , 2-Listener, 3-MessageServer
the following is my server code :

#include "schedule_MgmtI.h"
#include <CosNamingC.h>

int main( int argc, char *argv[] )
{
  try
  {
    cout << "Starting Schedule Management Server" << endl;
    CORBA::ORB_var orb = CORBA::ORB_init( argc, argv );
    
    CORBA::Object_var obj = orb->resolve_initial_references( "RootPOA" );

    PortableServer::POA_var poa = PortableServer::POA::_narrow( obj.in() );

    PortableServer::POAManager_var mgr = poa->the_POAManager();

    mgr->activate();

    CORBA::Object_var naming_obj = orb->resolve_initial_references("NameService");

    CosNaming::NamingContext_var  root = CosNaming::NamingContext::_narrow( naming_obj.in() );


    if (CORBA::is_nil(root.in()))
    {
	  cerr << "Nil Naming Context reference" << endl;
	  throw 0;
    }
    else
    {
	  cout << "***Resolved Naming Service" << endl;
    }

    CosNaming::Name name;
    name.length(1);
    name[0].id = CORBA::string_dup("schedule_Mgmt");

    try {
	      CORBA::Object_var dummy = root->resolve(name);
        }
    catch (const CosNaming::NamingContext::NotFound &)
        {
	      cout << "***Bind \"schedule_Mgmt\" context to Naming Service context" << endl;
	      CosNaming::NamingContext_var dummy = root->bind_new_context(name);
        }
	
 	name.length(2);
	name[1].id = CORBA::string_dup("config");

	schedule_Mgmt_config_i* config_servant = new schedule_Mgmt_config_i();

        PortableServer::ObjectId_var oid = poa->activate_object( config_servant );

        CORBA::Object_var config_obj  = poa->id_to_reference( oid.in() );

	root->rebind(name, config_obj.in());
	
		
	 name.length(3);
	 
  	  name[2].id = CORBA::string_dup("Listener");
   	
    	schedule_Mgmt_Listener_i* Listener_servant = new schedule_Mgmt_Listener_i();
    
        PortableServer::ObjectId_var oid1 = poa->activate_object( Listener_servant );
    	
        CORBA::Object_var Listener_obj  = poa->id_to_reference( oid1.in() );
    	
    	root->rebind(name, Listener_obj.in());
    	
    	
    	name.length(4);
    	name[3].id = CORBA::string_dup("MessageServer");
    		
    	schedule_Mgmt_MessageServer_i* MessageServer_servant = new schedule_Mgmt_MessageServer_i();
    	
        PortableServer::ObjectId_var oid2 = poa->activate_object( MessageServer_servant );
    	 	
        CORBA::Object_var MessageServer_obj  = poa->id_to_reference( oid2.in() );
    		
    	root->rebind(name, MessageServer_obj.in());
	 
    cout << "Server is running and waiting" << endl;

    orb->run();
    

    orb->destroy();

    return 1;
  }
  catch (CORBA::Exception& ex)
  {
    cerr << "CORBA exception: " << ex << endl;
  }
  catch(CORBA::SystemException&) {
    cerr << "Caught CORBA::SystemException." << endl;
  }
  catch(...) {
    cerr << "Caught unknown exception." << endl;
  }
  return 1;
}

this is the following error message i get
CORBA exception: NotFound (IDL:omg.org/CosNaming/NamingContext/NotFound:1.0)
i dont know where im wrong
any suggestions ??
Thank You
vishy
|