C++ Server (Corba Communication)

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 :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#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
What ORB are you using?

What environment variables have you set?

What does your command-line look like when you invoke this program?

In my experience, this error occurs when the name service cannot be found. With most ORBs, you need to pass such information to the program either through environment variables or the command-line. Is the CORBA name service running? Are you passing location of the name service to the program?
Im using Tao-Ace ORB , My NameService is up and Running. Im able to get my server running if i add only the config interface , if i add the other 2 interfaces , my server throws the above error.

1
2
3
4
5
6
7
8
9
10
11
12
13
# load  environment

cd /cc/smc3/ss_pool4/elem_level_mgmt/tools/Schedule_Mgmt/Schedule_Mgmt/src

# definitions for name service
PROTO=iiop
PORT=5341

echo "using $PROTO://172.21.132.249:$PORT" >&2
echo "$PROTO:172.21.132.249:$PORT" >~/C++/vishynew/Schedule_Mgmt/src/nameserv

exec /opt/java1.4/jre/bin/tnameserv -ORBInitialPort $PORT

thats my name service start script, im using a java client n a c++ server.
Topic archived. No new replies allowed.