I know this issue has been raised a number of times but I'm still having problems building a solution.
I have the Bodgitt & Scarper DBMain interface. I'm using a DabaseFactory class to create a local or RMI connection based on command line arguments. I would like a single interface class to be used for both local and remote.
As an example, there's a read method in DBMain
public
String [] read(int recNo) throws RecordNotFoundException;
and I have implemented
public class RecordNotFoundException extends IOException
So in terms of an exception hierarchy I should have
RecordNotFoundException
IOException
RMIException
I've tried taking the exceptions, RecordNotFoundException & DuplicateKeyException thrown by each method in the DBMain interface and have them extend IOException. And I've extended the DBMain interface in a new DatabaseInterface to give some additional methods. My idea was that I could simply use DatabaseInterface and if in local mode throw an IOException in local mode, and RemoteException in RMI mode. I belive this is possible as I can also throw the same or a narrower exception. For exampe with the read Interface method which throws RecordNotFoundException.
But though the code compiles, when I run RMIC tool to generate stubs for remote mode I seem to get errors such as
error: suncertify.db.DBMain is not a valid remote interface: method java.lang.String read(int)[] must throw java.rmi.RemoteException
thanks
Tim