[omniORB] Can't send CORBA-Any converted from structure which contains enum

Kaneiwa Tomohide kaneiwa at nagoya.ydc.co.jp
Thu May 29 21:35:22 BST 2008


Hi.

I'm a new on omniORB.
Now I am trying to use CORBA-Any on omniORB4, but It doesn't work as
expected.
When I send CORBA-Any converted from struct which contains enum type,
server outputs error messages as below.( several times )

--------------------------------------------------------------------
message:
omniORB: Assertion failed. This indicates a bug in the application
using omniORB, or maybe in omniORB itself.
file: tcParser.cc
line: 297
info: 0
--------------------------------------------------------------------

I attach source code (echo.idl/eg2_clt.cc/eg2_impl.cc) , which is
modified from omni-sample.

It works fine on omniORB3, but not work on omniORB4.
It does'nt work both on 32bits and 64bits ELF.

My environments is below.
UP-UX B.11.31
aCC complier

Any advise is very appreciated.
Thanx.

T.Kaneiwa.


-----echo.idl ------
#ifndef __ECHO_IDL__
#define __ECHO_IDL__

enum testEnum { e1_, e2_, e3_ };

struct test{
testEnum enum_;
};

interface Echo {
string echoString1(in string mesg, in test t);
string echoString2(in string mesg, in any a);
};

#endif // __ECHO_IDL__



-----eg2_clt.cc------
// eg2_clt.cc - This is the source code of example 2 used in Chapter 2
// "The Basics" of the omniORB user guide.
//
// This is the client. The object reference is given as a
// stringified IOR on the command line.
//
// Usage: eg2_clt <object reference>
//

#include <echo.hh>

#ifdef HAVE_STD
# include <iostream>
# include <fstream>
using namespace std;
#else
# include <iostream.h>
#endif


static void hello(Echo_ptr e)
{
CORBA::String_var src = (const char*) "Hello!";

test t;
t.enum_=e3_;
CORBA::String_var dest = e->echoString1(src,t);
cout << "I said, \"" << (char*)src << "\"." << endl
<< "The Echo object replied, \"" << (char*)dest <<"\"." << endl;
CORBA::Any any;
t.enum_=e3_;
any <<= t;
// any <<= e3_;
CORBA::String_var dest2 = e->echoString2(src,any);
cout << "I said, \"" << (char*)src << "\"." << endl
<< "The Echo object replied, \"" << (char*)dest2 <<"\"." << endl;

}

//////////////////////////////////////////////////////////////////////

int main(int argc, char** argv)
{

try {
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

if( argc != 2 ) {
cerr << "usage: eg2_clt <object reference>" << endl;
return 1;
}

CORBA::Object_var obj = orb->string_to_object(argv[1]);
Echo_var echoref = Echo::_narrow(obj);
if( CORBA::is_nil(echoref) ) {
cerr << "Can't narrow reference to type Echo (or it was nil)." << endl;
return 1;
}
for (CORBA::ULong count=0; count<10; count++)
hello(echoref);

orb->destroy();
}
catch(CORBA::TRANSIENT&) {
cerr << "Caught system exception TRANSIENT -- unable to contact the "
<< "server." << endl;
}
catch(CORBA::SystemException& ex) {
cerr << "Caught a CORBA::" << ex._name() << endl;
}
catch(CORBA::Exception& ex) {
cerr << "Caught CORBA::Exception: " << ex._name() << endl;
}
catch(omniORB::fatalException& fe) {
cerr << "Caught omniORB::fatalException:" << endl;
cerr << " file: " << fe.file() << endl;
cerr << " line: " << fe.line() << endl;
cerr << " mesg: " << fe.errmsg() << endl;
}
return 0;
}



-----eg2_impl.cc------
// eg2_impl.cc - This is the source code of example 2 used in Chapter 2
// "The Basics" of the omniORB user guide.
//
// This is the object implementation.
//
// Usage: eg2_impl
//
// On startup, the object reference is printed to cerr as a
// stringified IOR. This string should be used as the argument to
// eg2_clt.
//

#include <echo.hh>

#ifdef HAVE_STD
# include <iostream>
using namespace std;
#else
# include <iostream.h>
#endif

class Echo_i : public POA_Echo
{
public:
inline Echo_i() {}
virtual ~Echo_i() {}
// virtual char* echoString(const char* mesg);
char* echoString1(const char* mesg, const test& t);
char* echoString2(const char* mesg, const ::CORBA::Any& a);
};


//char* Echo_i::echoString(const char* mesg)
//{
// cout << "Upcall " << mesg << endl;
// return CORBA::string_dup(mesg);
//}

char* Echo_i::echoString1(const char* mesg, const test& t) {
cout << "Upcall " << mesg << " t.enum_="<< t.enum_ << endl;
return CORBA::string_dup(mesg);
}
char* Echo_i::echoString2(const char* mesg, const ::CORBA::Any& a) {
cout << "Upcall " << mesg << endl;
// testEnum e;
// if (a >>= e) { cout<<"testEnum="<<e<<endl; }
test* t=0;
if (a >>= t) { cout<<"testEnum="<<t->enum_<<endl; }
return CORBA::string_dup(mesg);
}

//////////////////////////////////////////////////////////////////////

int main(int argc, char** argv)
{
try {
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);

Echo_i* myecho = new Echo_i();

PortableServer::ObjectId_var myechoid = poa->activate_object(myecho);

// Obtain a reference to the object, and print it out as a
// stringified IOR.
obj = myecho->_this();
CORBA::String_var sior(orb->object_to_string(obj));
cout << (char*)sior << endl;

myecho->_remove_ref();

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

orb->run();
}
catch(CORBA::SystemException& ex) {
cerr << "Caught CORBA::" << ex._name() << endl;
}
catch(CORBA::Exception& ex) {
cerr << "Caught CORBA::Exception: " << ex._name() << endl;
}
catch(omniORB::fatalException& fe) {
cerr << "Caught omniORB::fatalException:" << endl;
cerr << " file: " << fe.file() << endl;
cerr << " line: " << fe.line() << endl;
cerr << " mesg: " << fe.errmsg() << endl;
}
return 0;
}



-- 
**********************************
中部コンサルティング事業部
兼岩 知英(Kaneiwa Tomohide)
kaneiwa at nagoya.ydc.co.jp
**********************************


***** 秘密保持について ********************************************
この電子メール(添付ファイル等を含む)は、宛先として意図した特定の相手に送信
したものであり、秘匿特権の対象になる情報を含んでいます。
もし、意図した相手以外の方が受信された場合は、このメールを破棄していただくと
ともに、このメールについて、一切の開示、複写、配布、その他の利用、または記載
内容に基づくいかなる行動もされないようにお願いします。
*******************************************************************




More information about the omniORB-list mailing list