Discussion:
[omniORB] Caught a CORBA:: UNKNOWN error (IDL sequence type)
janarbek
2007-10-07 14:35:04 UTC
Permalink
Dear all, I hope some one could help me with following code.

First, I have following IDL

typedef sequence<short> seqShort;
interface shortSeqTestServer {
void setSize(inout short size);
void acceptType(inout seqShort value);
seqShort returnType();
};

Second in my server code,

My servan and servant implementation is as follows.

class shortSeqTestServer_i : public POA_shortSeqTestServer
{
private:
seqShort data;
public:
inline shortSeqTestServer_i() {}
virtual ~shortSeqTestServer_i() {
}

virtual void setSize(CORBA::Short& size);
virtual void acceptType(seqShort& value);
virtual seqShort* returnType();
};

void shortSeqTestServer_i::setSize(CORBA::Short& size)
{
data.length(size);
for(int i=0;i<size;i++)
{
data[i] = (CORBA::Short)1;
}
}

void shortSeqTestServer_i::acceptType(seqShort& value)
{
// Do something
}
seqShort* shortSeqTestServer_i::returnType()
{
return &data;
}


Now, I am doing in my client.


shortSeqTestServer_var echoref1 = shortSeqTestServer::_narrow(obj1);

seqShort_var testPattern;
for (int j = 0; j<4; j++)
{
CORBA::Short size = j+4;
testPattern =new seqShort(size);
echoref1->setSize(size);
testPattern->length(size);

CORBA::Short i;
for (i = 0; i<size; i++)
testPattern[i] = 1;

testPattern = echoref1->returnType();
}


I got following error when I execute my client "Caught a CORBA:: UNKNOWN"!

I really don't know what is wrong with my code. It seems everything is Ok for me.
But I don't know.



==================================================================================================================================================================
Janarbek, Researcher.
Software Robot Research Team, ETRI(Electronics and Telecommunications Research Institute)
161 Kajong-Dong, Yusong-Gu, TAEJON, 305-350, KOREA
Email : ***@etri.re.kr
Phone : 82-42-860-1838
Fax : 82-42-860-6790
Cell Phone: 82-10-8692-8103
===================================================================================================================================================================


---------------------------------
Moody friends. Drama queens. Your life? Nope! - their life, your story.
Play Sims Stories at Yahoo! Games.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20071007/c9c6fa53/attachment.htm
Jason Etheridge
2007-10-08 01:36:40 UTC
Permalink
Post by janarbek
seqShort* shortSeqTestServer_i::returnType()
{
return &data;
}
The ORB takes ownership of the pointer returned, and will attempt to
deallocate it on the server side once it's marshalled the result for
sending to your client.

To fix:

seqShort* shortSeqTestServer_i::returnType()
{
return new seqShort(data);
}
--
Jason Etheridge mailto:***@etheridge.org
Loading...