This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
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 Java 8 in Action this week in the Java 8 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: 4926
    
  10

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: 4926
    
  10

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:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RMI and RemoteException
 
Similar Threads
jsp vs rmi
RMI:Placing different objects on different ports
My design...getting cloudier
Getting java.rmi.UnmarshalException: unrecognized method hash: method not supported by remote object
Does this guarantee a unique client?