[omniORB] error in 'bind_new_context'
Rene Jager
renej.frog at yucom.be
Wed Feb 4 09:15:06 GMT 2004
On Tue, 2004-02-03 at 18:39, Narayan Annamalai wrote:
> 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;
> }
// also add:
catch (std::exception const& ex)
{
std::cout << "std exception: " << ex.what() << std::endl;
}
// maybe that'll give you some more info
// grtz, renej
> 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/
>
> _______________________________________________
> omniORB-list mailing list
> omniORB-list at omniorb-support.com
> http://www.omniorb-support.com/mailman/listinfo/omniorb-list
More information about the omniORB-list
mailing list