Broken corba object references
Posted
by
cube
on Stack Overflow
See other posts from Stack Overflow
or by cube
Published on 2011-01-04T16:51:22Z
Indexed on
2011/01/04
16:53 UTC
Read the original article
Hit count: 307
I'm working on a homework and got stuck. The task is to serve objects using a default servant. But when I try to use the reference, weird things happen. Some part of corba prints a stack trace, but no exception is thrown. The problem happens when the server receives the reference and should call some method on it. The reference is then shortened and doesn't contain the object ID (which means that my servant implementation can't do anything reasonable).
This is the implementation of the servant, where the problem appears:
public class ModelFileImpl extends ModelFilePOA{
@Override
public String getName() {
try {
return new String(_poa().reference_to_id(_this_object()));
} catch (Throwable e) {}
assert false;
return null;
}
}
If I take _this_object().toString() inside the try block and put it into dior -i
i get this:
------IOR components-----
TypeId : IDL:termproject/idl/ModelFile:1.0
TAG_INTERNET_IOP Profiles:
Profile Id: 0
IIOP Version: 1.2
Host: 127.0.0.1
Port: 45954
Object key (URL): %AF%AB%CB%00%00%00%00%20Q%BA%F4%FF%00%00%00%01%00%00%00%00%00%00%00%01%0000%00%08RootPOA%00%00%00%00%08%00%00%00%02%00%00%00%00%14
Object key (hex): 0xAF AB CB 00 00 00 00 20 51 BA F4 FF 00 00 00 01 00 00 00 00 00 00 00 01 00 00 00 08 52 6F 6F 74 50 4F 41 00 00 00 00 08 00 00 00 02 00 00 00 00 14
-- Found 2 Tagged Components--
#0: TAG_CODE_SETS
ForChar native code set Id: ISO8859_1
Char Conversion Code Sets: UTF8
, Unknown TCS: 10020
ForWChar native code set Id: UTF16
WChar Conversion Code Sets: Unknown TCS: 10100
Unknown tag : 38
however the part of server that makes the reference and the client see the reference as
------IOR components-----
TypeId : IDL:termproject/idl/ModelFile:1.0
TAG_INTERNET_IOP Profiles:
Profile Id: 0
IIOP Version: 1.2
Host: 127.0.0.1
Port: 45954
Object key (URL): %AF%AB%CB%00%00%00%00%20Q%BA%F4%FF%00%00%00%01%00%00%00%00%00%00%00%02%00%00%00%08RootPOA%00%00%00%00%09modelPoa%00%00%00%00%00%00%00%10testModel1.MyIDL%14
Object key (hex): 0xAF AB CB 00 00 00 00 20 51 BA F4 FF 00 00 00 01 00 00 00 00 00 00 00 02 00 00 00 08 52 6F 6F 74 50 4F 41 00 00 00 00 09 6D 6F 64 65 6C 50 6F 61 00 00 00 00 00 00 00 10 74 65 73 74 4D 6F 64 65 6C 31 2E 4D 79 49 44 4C 14
-- Found 2 Tagged Components--
#0: TAG_CODE_SETS
ForChar native code set Id: ISO8859_1
Char Conversion Code Sets: UTF8
, Unknown TCS: 10020
ForWChar native code set Id: UTF16
WChar Conversion Code Sets: Unknown TCS: 10100
Unknown tag : 38
("modelPoa" (the name of the poa working with default clients) and "testModel1.MyIDL" (the identifier of the object) in the object key are missing in the first one)
I've tried sniffing the traffic and found out that the client still sends the correct reference.
This is how i create the references:
ret[i] = ModelFileHelper.narrow(modelFilePoa.create_reference_with_id(files[i].getBytes(), ModelFileHelper.id()));
And this is how i set up the server:
// init ORB
ORB orb = ORB.init(args, null);
// init POA
POA poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
// create the POA for the models.
Policy[] policies = {
poa.create_request_processing_policy(RequestProcessingPolicyValue.USE_DEFAULT_SERVANT),
poa.create_servant_retention_policy(ServantRetentionPolicyValue.NON_RETAIN),
poa.create_id_assignment_policy(IdAssignmentPolicyValue.USER_ID)
};
POA modelPoa = poa.create_POA("modelPoa", poa.the_POAManager(), policies);
modelPoa.the_POAManager().activate();
modelPoa.set_servant(new ModelFileImpl());
modelPoa.the_POAManager().activate();
ModelStoreImpl impl = new ModelStoreImpl(modelPoa);
// create the object reference
org.omg.CORBA.Object obj = poa.servant_to_reference(impl);
// ... store the IOR file ...
orb.run();
I'd be really grateful for any pointers (or references :-) )
© Stack Overflow or respective owner