[omniORB] MFC+omniORB3004 rootContext->resolve(name) crash

Alexios Ballas k994835@king.ac.uk
Fri, 25 Jan 2002 15:32:56 +0000


Hi there,

I have built a CORBA client (NT 4.0) running perfectly as a WIN32 console 
application.

It is contacting a CORBA server (NT4.0)
through OmniNames (running on the same machine as CORBA server does).

I can communicate with Omninames and the CORBA server perfectly.

THE PROBLEM:

I am taking the SAME code and putting it in my MFC application.
Everything compiles good, but when I run the program an "unknown exception" 
is thrown at this line:
rootContext->resolve(name)

It does contact OmniNames because when I set the "name" parameter incorrectly,
an "CosNaming::NamingContext::NotFound" exception is thrown, which means 
that it knows that the name is incorrect.


Any ideas what might be wrong??
Any help will be appreciated!

thanks
Alexis Ballas

\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

The CODE is as follows:

static CORBA::Object_ptr
getObjectReference(CORBA::ORB_ptr orb)
{
   CosNaming::NamingContext_var rootContext;

   try {
     // Obtain a reference to the root context of the Name service:
     CORBA::Object_var obj = orb->resolve_initial_references("NameService");


     // Narrow the reference returned.
     rootContext = CosNaming::NamingContext::_narrow(obj);
     if( CORBA::is_nil(rootContext) ) {
       //cerr << "Failed to narrow the root naming context." << endl;
       return CORBA::Object::_nil();
     }
   }
   catch(CORBA::ORB::InvalidName&) {
     // This should not happen!
     //cerr << "Service required is invalid [does not exist]." << endl;
     return CORBA::Object::_nil();
   }

   // Create a name object, containing the name test/context:
   CosNaming::Name name;
   name.length(2);

   name[0].id   = (const char*) "ProbeIT";       // string copied
   name[0].kind = (const char*) "data";          // string copied
   name[1].id   = (const char*) "ubi";
   name[1].kind = (const char*) "data";
   // Note on kind: The kind field is used to indicate the type
   // of the object. This is to avoid conventions such as that used
   // by files (name.type -- e.g. test.ps = postscript etc.)

   try {
     // Resolve the name to an object reference.
     return 
rootContext->resolve(name); 
<====================================================HERE
   }
   catch(CosNaming::NamingContext::NotFound&) {
     // This exception is thrown if any of the components of the
     // path [contexts or the object] aren't found:
     //cerr << "Context not found." << endl;
   }
   catch(CORBA::COMM_FAILURE&) {
     //cerr << "Caught system exception COMM_FAILURE -- unable to "
         //<< "contact the naming service." << endl;
   }
   catch(CORBA::SystemException&) {
     //cerr << "Caught a CORBA::SystemException while using the "
      //   << "naming service." << endl;
   }
   catch(...) {
     //cerr << "Caught unknown exception." << endl;
   }
   return CORBA::Object::_nil();
}