• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Concerns about exporting objects - unable to unexport

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 291
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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'.
 
Stepan Kolesnik
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic