[omniORB] error in 'bind_new_context'

Narayan Annamalai narayan_annamalai at yahoo.com
Tue Feb 3 09:39:47 GMT 2004


Hi all,
I am using omnbORB-4.0.3 in windows 2000. I have
written a c++ app very similar to the one in eg3_Impl
(example 3 echo server) provided in the distribution,
which fails on 'bind_new_context' call. Note that
example 3 works fine.
The code is attached:

CORBA::Boolean TheOrb::bindObjectToName(std::string
name, CORBA::Object_ptr objRef)
{
  CosNaming::NamingContext_var rootContext;
  
  try 
    {
      /* orb as define in a included header file as
CORBA::ORB_var                 orb; */

      CORBA::Object_var obj;
      obj =
orb->resolve_initial_references("NameService");
       
      rootContext =
CosNaming::NamingContext::_narrow(obj);
      if( CORBA::is_nil(rootContext) ) 
	{
	  cerr << "Failed to narrow the root naming context."
<< endl;
	  return 0;
	}
    }
  catch (CORBA::ORB::InvalidName& ex) 
    {
       cerr << "Service required is invalid [does not
exist]." << endl;
      return 0;
    }

  try 
    {
      //
      // Bind a context called "IServices" to the root
context:
      //
      CosNaming::Name contextName;
      contextName.length(1);
      contextName[0].id   = (const char*) "IServices";

      contextName[0].kind = (const char*) "IContext"; 
      
      CosNaming::NamingContext_var testContext;
      try 
	{
	  // Bind the context to root.
	  testContext =
rootContext->bind_new_context(contextName);
         /*** THIS IS WHERE IT FAILS ****/
        }
      catch(CosNaming::NamingContext::AlreadyBound&
ex) 
	{
	  CORBA::Object_var obj;
	  obj         = rootContext->resolve(contextName);
	  testContext =
CosNaming::NamingContext::_narrow(obj);

	  if( CORBA::is_nil(testContext) ) 
	    {
	      cerr << "Failed to narrow naming context." <<
endl;
             return 0;
	    }
	}
	catch(CosNaming::NamingContext::InvalidName& ex) 
	{
	      std::cout<<" Failed: Invalid Name, returning
"<<endl;
	  	return 0;
	}

	catch(CosNaming::NamingContext::CannotProceed& ex) 
	{
	      std::cout<<" Failed: Cannot Proceed, returning
"<<endl;
	  	return 0;
	}

	catch(CosNaming::NamingContext::NotFound& ex) 
	{
	      std::cout<<" Failed: Not Found, returning
"<<endl;
	  	return 0;
	}
        catch(CORBA::Exception& ex)
        {
           std::cout<<" General Corba exception:
"<<endl;
        }
	catch(...)
        {
              std:cout<<"other exceptions, not known
"<<endl;
              return 0;
        }
------------------------------------------------------
The exception is caught by the last catch clause (how
do I print the message of the exception?), thus not
giving a clue as to why the exception is happening? 

I compiled the program with vc6 (cl) and linked it
against appropriate omniORB403 and omnitread30
libraries. I also started omniNames before executing
the app. 

Any ides/suggestions on what I am missing here?

Thanks,
Narayan.

__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/



More information about the omniORB-list mailing list