wood burning stoves 2.0*
The moose likes Distributed Java and the fly likes RMI and RemoteException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "RMI and RemoteException" Watch "RMI and RemoteException" New topic
Author

RMI and RemoteException

Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5139
    
  12

Hi,

A little bit playing around with RMI. I have the following (simple) interface:


and an implementation that's even simpler:


I was wondering if it's possible to work with RMI but in your implementation get rid of the RemoteException, so something like:


and an implementation:

so you could use the same interface for a local implementation, another network technology,... or are you stuck on this RemoteException?

Kind regards,
Roel


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Oscar Costa
Ranch Hand

Joined: Feb 05, 2009
Posts: 31

Hello Roel,

You can use an application exception too. But you need to throw the RemoteException. This exception is used when a remote method invocation fails...

See at http://java.sun.com/j2se/1.5.0/docs/guide/rmi/spec/rmi-objmodel5.html


"Do or do not... there is no try!" - Jedi Master Yoda
> SCJP 5 : SCWCD 5 : SCBCD 5 <
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5139
    
  12

Oscar,

Thanks for your quick reply.

after some experimenting following conclusions:
- PowerService without "extends Remote" --> ClassCastException when trying to run the client
- method from PowerService without "throws RemoteException" --> RemoteException("remote object implements illegal remote interface") when trying to run the server

so it's required to add RemoteException to all of your method signatures in your interface. The best you can do to depend as little to rmi as possible, is having something like this:
 
Don't get me started about those stupid light bulbs.
 
subject: RMI and RemoteException
 
Similar Threads
jsp vs rmi
RMI:Placing different objects on different ports
Does this guarantee a unique client?
My design...getting cloudier
Getting java.rmi.UnmarshalException: unrecognized method hash: method not supported by remote object