aspose file tools*
The moose likes Distributed Java and the fly likes Concerns about exporting objects - unable to unexport Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Concerns about exporting objects - unable to unexport" Watch "Concerns about exporting objects - unable to unexport" New topic
Author

Concerns about exporting objects - unable to unexport

Stepan Kolesnik
Greenhorn

Joined: Sep 04, 2007
Posts: 7
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?
Edward Harned
Ranch Hand

Joined: Sep 19, 2005
Posts: 291

I assume SERVICES is the name of your implementation class.
I assume UBServices is the name of your interface that extends Remote.

This line doesn't seem to make sense:
stub = (UBServices) UnicastRemoteObject.exportObject(SERVICES, 0);

You don't export a class name, perhaps the lines should be
SERVICES = services = new SERVICES(); and export the lowercase services.

Exporting returns a remote object, not a stub. The RMI Runtime makes a stub available to a client.

Un-exporting uses the same format as exporting: 'services', not 'stub'.


Ed's latest article: A Java Parallel Calamity http://coopsoft.com/ar/Calamity2Article.html
Stepan Kolesnik
Greenhorn

Joined: Sep 04, 2007
Posts: 7
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Concerns about exporting objects - unable to unexport
 
Similar Threads
Reg. Exception hierarchy
Problems with getSystemJavaCompiler() - reg.
Exception: Connection refused to host
Reg. Exception Handling
Reg:: HTMLParser