[omniORB] About building CORBA shared library

zhang ji zsfunl@yahoo.com
Fri, 1 Mar 2002 22:30:25 -0800 (PST)


Hi all,

I have two questions:

1.) Can we build a CORBA shared library under omniORB?
For some reasons, in my porject I want to implement
some common classes in shared library, they will be
loaded from the library when client request.

2.) If we can, Can you tell me what is the problem I
met from below demo codes?

2.1)The IDL file is very simple, it make adding
computing for client:
"
interface test{
        double add(in double x,in double y);
};
"

2.2)The Implement c++ header file is below
"
class test_i : public POA_test,
                public
PortableServer::RefCountServantBase
{
        public:
        double a,b;
        test_i();
        virtual ~test_i();

        CORBA::Double add(CORBA::Double x,  
                          CORBA::Double y);
};
"
The test_i will respond with the client by returning
x+y;
I built the shared library in IRIX 6.5.

2.3) I can load the test_i object from the shared
library, but I can not get its object reference.Below
is the regiester source code:
"
void main(int argc,char **argv)
{
       CORBA::ORB_var orb = CORBA::ORB_init(argc,
argv, "omniORB3");

       // Obtain a reference to the root POA.
        CORBA::Object_var obj =
orb->resolve_initial_references("RootPOA");
        PortableServer::POA_var poa =
PortableServer::POA::_narrow(obj);
       
        test_i * b = new test_i();
        PortableServer::ObjectId_var mytest =
poa->activate_object(b);
        test_var obj1 = b->_this();//?Probelm here?//
        CORBA::String_var
sior(orb->object_to_string(obj1));
        cerr << "'" << (char*)sior << "'" << endl;
        
        b->_remove_ref();

        PortableServer::POAManager_var pman =
poa->the_POAManager();
        pman->activate();

        orb->run();
        orb->destroy();
}
"

It can be compiled and when I run it, I get such error
information:
"
omniORB: Assertion failed.  This indicates a bug in
the application using
omniORB, or maybe in omniORB itself. e.g. using the
ORB after it has
been shut down.
 file: ../omniInternal.cc
 line: 743
 info: pof
Abort (core dumped)
"

It happened just at " test_var obj1 = b->_this(); ".

Any advices and comments on it are welcomed!!

Thanks,
shifeng