File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "RMI and RemoteException" Watch "RMI and RemoteException" New topic

RMI and RemoteException

Roel De Nijs

Joined: Jul 19, 2004
Posts: 8372


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,

SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
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

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

Joined: Jul 19, 2004
Posts: 8372


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:
I agree. Here's the link:
subject: RMI and RemoteException
It's not a secret anymore!