Your Java code is assigning a marshalled map class instance as the message string with type "Modify" and is sending that message.
Your C++ code that you provided starts with line:
STAFString message = queueMap->get("message")->asString();
So, it appears you have already iterated through the message list from a
QUEUE LIST request and are processing an entry in this message list and
this line is obtaining the message string from a queued message. So,
since your Java code is assigning a marshalled map class instance to the
message string, your C++ code should be expecting a marshalled map class
instance. However, your C++ code is expecting the message to be a
marshalled list so it is failing when you try to assigning the
unmarshalled root object (a map class object) to a list.
You are printing the marshalled message in your C++ code as follows.
Please provide the exact complete content of that marshalled message. That
will show me exactly what type of message it is (and confirm whether what
I described above is happening).
cout << message << endl;
--------------------------------------------------------------
Sharon Lucas
IBM Austin, [email protected]
(512) 286-7313 or Tieline 363-7313
From: "Dedhia, Hardik" <[email protected]>
To: <[email protected]>, Sharon Lucas/Austin/IBM@IBMUS
Date: 07/27/2011 09:50 AM
Subject: Marshalling problem
Hi,
I am trying to send messages from a Java Interface to a c++ program using
the following code:
STAFHandle modify_handle = handle;
STAFMapClassDefinition modifyClass = new
STAFMapClassDefinition("STAF/Test/LogRecord");
modifyClass.addKey("message", "Message");
modifyClass.addKey("param", "Parameter");
modifyClass.addKey("value", "New value");
STAFMarshallingContext mc = new STAFMarshallingContext();
mc.setMapClassDefinition(modifyClass);
Map modifyRecord = modifyClass.createInstance();
modifyRecord.put("message", "MODIFY");
modifyRecord.put("param", "ITERATIONS");
modifyRecord.put("value", "200");
mc.setRootObject(modifyRecord);
String send = mc.marshall();
String wrappedMessage = STAFUtil.wrapData(send);
System.out.println(wrappedMessage + hammer_handle);
modify_handle.submit2(cyclMachine, "QUEUE", "QUEUE TYPE
Modify MESSAGE " + wrappedMessage + " HANDLE " + hammer_handle);
On the c++ code side, I use a QUEUE LIST to obtain the queued messages and
process them. In Case of messages with TYPE Modify – this is the code I
use to un-marshall the map:
STAFString message = queueMap->get("message")->asString();
259 cout << message << endl;
260 STAFObjectPtr mc = STAFObject::unmarshall(message,
kSTAFIgnoreIndirectObjects);
261 STAFObjectPtr modifyList = mc->getRootObject();
262 STAFObjectIteratorPtr iter = modifyList->iterate();
263
264 while(iter->hasNext())
265 {
266 STAFObjectPtr modifyQueueMap = iter->next();
267 STAFString messg =
modifyQueueMap->get("message")->asString();
268 param = modifyQueueMap->get("param")->asString();
269 value = modifyQueueMap->get("value")->asString();
270 //param = param_str.c_str();
271 //value = value_str.c_str();
272 cout << "Message: " << messg << endl
273 << "Parameter to be changed: " << param <<
endl
274 << "New Value : " << value << endl;
275
276 int corrNum = NameConv(messg, handle_from);
277 int perform_action = perform_action =
SwitchCase(corrNum);
278 int act_prfmd = 0;
279 if(perform_action == 1)
280 act_prfmd = switch_to_action(corrNum,
handle_from);
281 return corrNum;
282
283 }
It was working fine when I was sending messages to and from c++ programs
but when I added the Java interface it gives me :
terminate called after throwing an instance of
'STAFInvalidObjectException'
Can you please point me to the fault in my code?
Thanks so much,
Hardik.
<<image/gif>>
------------------------------------------------------------------------------ Got Input? Slashdot Needs You. Take our quick survey online. Come on, we don't ask for help often. Plus, you'll get a chance to win $100 to spend on ThinkGeek. http://p.sf.net/sfu/slashdot-survey
_______________________________________________ staf-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/staf-users
