[omniORB] Getting a servant pointer given a reference

Russell Kliese russell at eminence.com.au
Tue Apr 12 16:46:55 BST 2005


Hello All,

I'm running up against a problem that has been touched upon before.  
Unfortunatly, there hasn't been a clear solution that I have been able 
to find so I am hoping someone on the list might be able to shed some light.

In a nutshell, I am trying to figure out a way to get a pointer to the 
servent object given a reference.

So far, I have tried the following:

NodeProxy* NodeProxy::getNodeProxy (dom::Node_ptr node) {

    PortableServer::POA_var poa = server->getPOA() ;
    PortableServer::ServantBase* serv = poa->reference_to_servant(node);
   
    NodeProxy* nodeProxy = dynamic_cast<NodeProxy*>(serv);
    // check to make sure it's not null
    return nodeProxy;
}   

With omniORB3 I get the following:

omniORB: ERROR -- trying to release an object with reference count <= 0.
 CORBA::release() may have been called too many times on an object
 reference.

I have experimented with _add_ref() to no avail.

With omniORB4 I am just getting a segfault further down the track ;(

I am writing a CORBA interface to xerces-c.  For the idl, I have simply 
grabbed the dom.idl (level 1) from w3c website.

In the various Node implementation objects (Node_i, Element_i etc. ), I 
am passing around xerces references from NodeProxy objects that are 
inherited by the various Node implementation objects. The node proxy 
object contains node functions common to the various node types.

The inheritance hierarchy can be viewed at: 
http://www.kliese.wattle.id.au/~russell/class_diagram.png

Is there a recommended way of retrieving a pointer to the servant given 
an object reference? I have though about the design and I can't see a 
simple way to remove this requirement for obtaining a pointer to the 
servant without making things far more complicated.

Thanks in advance for any help or advice,

Russell



More information about the omniORB-list mailing list