• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Does the client RMI object need to extend Remote?

 
Lara McCarver
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the object which the client gets from the RMI Naming server need to extend Remote? I thought that because this application uses RMI, any method could run into a communication problem (e.g. the network could go down) and end up throwing a RemoteException. Therefore, the RMI object which the client uses should implement Remote, and each of its methods, including the constructor, would throw a RemoteException.

But in the book SCJD, the DBClient interface does not implement Remote. I looked at the sample code, and it just looks like this:



So... does the object which the RMI Naming server return actually need to implement the Remote interface?
 
Samuel Pessorrusso
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the Sun's tutorial
http://java.sun.com/j2se/1.4.2/docs/guide/rmi/index.html
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11914
209
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Lara,

Whenever a book like that is written, the author has the problem of wanting to provide all the information necessary to pass the exam, but without giving away a complete solution. One of the best ways to do this (IMHO) is to provide the answers in separate chapters, then do something slightly different in the example project so that the example project's code can't be copied and pasted.

In Max's book (and in the second edition) we describe that RemoteException must be declared to be thrown in methods that will be called remotely in the chapter on RMI. However we then deliberately do something slightly different in the sample assignment by having all DBClient's methods throw IOException, which is the superclass of RemoteException.

In the second edition we have dedicated several paragraphs to describing what parts of our sample assignment are deliberately harder than the real assignment, and which parts are deliberately easier.

Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic