Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RMI and RemoteException

 
Roel De Nijs
Sheriff
Posts: 10223
129
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Oscar Costa
Ranch Hand
Posts: 31
Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Roel De Nijs
Sheriff
Posts: 10223
129
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic