[omniORB] Client fails to contact naming service

Jonas Reimers jonas.reimers@se.transport.bombardier.com
Tue, 26 Jun 2001 14:57:13 +0100


-
Hello!

I have a client inside a DLL. When the DLL is loaded the client is supposed to
connect to the name service, but all I get is COMM::FAILURE
After some searching I belive that the failure is when narrowing the returned
ref. This works just fine with my server

The important part off the source looks like this:

CLIENT:

extern "C" int APIENTRY DllMain(HINSTANCE hInstance, DWORD ul_reason_for_call,
LPVOID lpReserved)
{

  switch(ul_reason_for_call){

     case DLL_PROCESS_DETACH:
          orb->destroy();
          break;

     case DLL_PROCESS_ATTACH:

          try{//When the DLL is loaded connect to NameService

              int argc = 3;
               char * argv[3];
               argv[0] = "OPCS";
               argv[1] = "-ORBInitRef";
               argv[2] = "NameService=corbaname::localhost:2809";

               orb = CORBA::ORB_init(argc,argv,"omniORB3");

               CORBA::Object_var obj = getObjectReference(orb);

               Op_ref = Op::_narrow(obj);

          }

     catch{
     .
     .
     EXCEPTION HANDLING
     .
     .
     }
   return 1;
}

static CORBA::Object_ptr getObjectReference(CORBA::ORB_ptr orb)
{

     CosNaming::NamingContext_var rootContext;

     try{

               //Get the root naming context.
               CORBA::Object_var obj;

               obj = orb->resolve_initial_references("NameService");

               //Narrow the reference returned.
               rootContext = CosNaming::NamingContext::_narrow(obj); // THE
FAILURE SEEMS TO BE HERE?

               if(CORBA::is_nil(rootContext))
               {
                    MessageBox(NULL,"Failed to narrow the root naming context."
,"CORBA", MB_ICONWARNING);

                    return CORBA::Object::_nil();
               }
          }

Running omninames with ORBtraceLevel 20 gives this output:

C:\corba\Orb\bin\x86_win32>omninames -ORBtraceLevel 20
omniORB: The omniDynamic library is not linked.
omniORB: Initialising incoming rope factories.
omniORB: strand Rope::incrRefCount: old value = 0
omniORB: Starting incoming rope factories.
omniORB: Activating: key<0x4e616d6553657276696365>
omniORB: Activating: root/<0>
omniORB: Activating: root/<16777216>
omniORB: strand Rope::incrRefCount: old value = 1
omniORB: strand Rope::decrRefCount: old value = 2
omniORB: Creating ref to local: key<0x4e616d6553657276696365>
 target id      : IDL:omg.org/CORBA/Object:1.0
 most derived id: IDL:omg.org/CosNaming/NamingContextExt:1.0
omniORB: strand Rope::incrRefCount: old value = 1
omniORB: strand Rope::decrRefCount: old value = 2
omniORB: Creating ref to local: root/<0>
 target id      : IDL:omg.org/CORBA/Object:1.0
 most derived id: IDL:omg.org/CosNaming/NamingContextExt:1.0
omniORB: createObjRef -- reusing reference from local ref list.
omniORB: Ref to: key<0x4e616d6553657276696365> -- deleted.
omniORB: strand Rope::incrRefCount: old value = 1
omniORB: strand Rope::decrRefCount: old value = 2
omniORB: Creating ref to local: key<0x4e616d6553657276696365>
 target id      : IDL:omg.org/CORBA/Object:1.0
 most derived id: IDL:omg.org/CosNaming/NamingContextExt:1.0
omniORB: strand Rope::incrRefCount: old value = 1
omniORB: strand Rope::decrRefCount: old value = 2
omniORB: Creating ref to local: root/<16777216>
 target id      : IDL:omg.org/CORBA/Object:1.0
 most derived id: IDL:omg.org/CosNaming/NamingContextExt:1.0
omniORB: createObjRef -- reusing reference from local ref list.
omniORB: Ref to: key<0x4e616d6553657276696365> -- deleted.
omniORB: strand Rope::incrRefCount: old value = 1
omniORB: strand Rope::decrRefCount: old value = 2
omniORB: createObjRef -- reusing reference from local ref list.
omniORB: strand Rope::incrRefCount: old value = 0
omniORB: Creating ref to remote: root<0>
 target id      : IDL:omg.org/CORBA/Object:1.0
 most derived id: IDL:Op:1.0
omniORB: createObjRef -- reusing reference from local ref list.
omniORB: strand Rope::incrRefCount: old value = 1
omniORB: strand Rope::decrRefCount: old value = 2
omniORB: createObjRef -- reusing reference from local ref list.
omniORB: strand Rope::incrRefCount: old value = 0
omniORB: Creating ref to remote: root<0>
 target id      : IDL:omg.org/CORBA/Object:1.0
 most derived id: IDL:Op:1.0
omniORB: createObjRef -- reusing reference from local ref list.

Tue Jun 26 14:53:35 2001:

Read log file successfully.
omniORB: Creating ref to local: key<0x4e616d6553657276696365>
 target id      : IDL:omg.org/CosNaming/NamingContextExt:1.0
 most derived id: IDL:omg.org/CosNaming/NamingContextExt:1.0
Root context is
IOR:010000002b00000049444c3a6f6d672e6f72672f436f734e616d696e672f4e616d696e67436f6e

6578744578743a312e300000010000000000000027000000010100000d00000031302e3234302e37372e3733003af90a0b

00004e616d6553657276696365
Checkpointing Phase 1: Prepare.
omniORB: createObjRef -- reusing reference from local ref list.
omniORB: createObjRef -- reusing reference from local ref list.
omniORB: createObjRef -- reusing reference from local ref list.
omniORB: createObjRef -- reusing reference from local ref list.
Checkpointing Phase 2: Commit.
Checkpointing completed.
omniORB: strand Ripper: start.
omniORB: scavenger : start.
omniORB: tcpSocketMTfactory Rendezvouser: start.
omniORB: tcpSocketMTfactory Rendezvouser: block on accept()
omniORB: scavenger : scanning connections
omniORB: scavenger : scanning connections
omniORB: scavenger : scanning connections
omniORB: scavenger : scanning connections

My .cfg file lokks like this:

# omniOrb configuration file - basic options
#
ORBInitRef NameService=corbaname::localhost:2809
#
#ORBDefaultInitRef corbaname::ORBInitialHost#services
#
#NAMESERVICE
#IOR:010000002b00000049444c3a6f6d672e6f72672f436f734e616d696e672f4e616d696e67436f6e746578744578743a312e300000010000000000000027000000010100000d00000031302e3234302e37372e37330000f90a0b00

#
#ORBInitialHost GBGPC0019
#ORBInitialPort 2809

Using:

omniORB 303
Win NT 4 sp6
msvc++ 5.0 sp3

/Jonas