I hope someone can help with this.
I am trying to create a basic Object with a Remote interface and register the dynamic stub with the Glassfish registry (JNDI Context).
The following simple example will give the problem:
SimpleRemote simple = new SimpleRemote(); // this implements Remote
PortableRemoteObject.exportObject(simple);
Stub simpleStub = (Stub) PortableRemoteObject.toStub(simple);
ctx.rebind("Simple", simpleStub);
When I try and bind it (or rebind), it gives me the following exceptions:
java.lang.RuntimeException: Cant copy Serializable object:
root cause
org.omg.CORBA.BAD_OPERATION: The delegate has not been set! vmcid: 0x0 minor code: 0 completed: No
I have also tried explicitly getting the ORB and connecting the Stub manually which fixed the bind operation, but because the delegate is transient, I get the same exception when performing the lookup on the context. Code as follows:
SimpleRemote simple = new SimpleRemote(); // this implements Remote
PortableRemoteObject.exportObject(simple);
Stub simpleStub = (Stub) PortableRemoteObject.toStub(simple);
ORB myORB = (ORB) ctx.lookup("java:comp/ORB");
simpleStub.connect(myORB);
ctx.rebind("Simple", simpleStub);
// try to get it back - now the lookup fails with the same exception
Object simpleLookup = ctx.lookup("Simple");
Can anybody shed some light on why this might be happening and any workarounds that may be possible.
Thanks,
Matthew Parker
E-mail: matthew.parker_at_eads.com