I am working on my SCJD and have come across this one while programming RMI server:
This always throws java.rmi.NoSuchObjectException: object not exported on line commented with // THROWS. I have checked that stub is actually instantiated and is valid, I have even used it and it works! I have a feeling I am missing on some vital fundamentals of RMI or smth. Can anyone help and explain why this is happening?
Thanks for your answer, Edward, I need to clarify the code:
1) UBservices is an interface extending java.rmi.Remote; 2) SERVICES is a final variable holding a reference to an instance of UBServices implementation. Server receives in its constructor (I have put it 1st line to make things clear);
I still can't understand what I am doing wrong. My steps: 1) Instantiate an implementation of UBServices (services variable); 2) Pass it to constructor of Server (now Server's has the reference to implementation in its own SERVICES constant); 3) Create a stub from SERVICES (stub variable) by calling UnicastRemoteObject.exportObject 4) The code works fine, server works; 5) But then throws exception when trying to unexport stub;
P.S. Just saw you last comment, Edward, about unexporting the 'services'. Am going to try it when I am back, thanks! [ September 05, 2007: Message edited by: Stepan Kolesnik ]
subject: Concerns about exporting objects - unable to unexport