Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with RemoteException

 
No�l Verdurmen
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have an interface DB as given by sun, and I have an interface RemoteDB that extends DB and java.rmi.Remote.

In the class that is implementing RemoteDB (it also extends UnicastRemoteObject) I can only throw RemoteExceptions in the constructor. Adding a 'throw RemoteException' to the other methods will result in a compile-error.

Why can't these methods throw a RemoteException, although the class (implicitly) implements the java.rmi.Remote interface?

Any help is appreciated.
 
No�l Verdurmen
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way,

the RemoteDB interface is an empty interface.

In the Habibi book, a similar approach is used. I don't quite see the difference.
 
No�l Verdurmen
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm... I think I found out the problem.

RemoteException is a subclass of IOException and therefore, in the Habibi book, the class implementing the java.rmi.Remote and the RemoteDB interface declares it in the throws-clause.

That creates an other problem for me though. Since I wanted to expose the DB interface to the client exactly as it is described in the spec, I actually cannot do this without declaring a RemoteException in the throws-clause. And changing the DB interface to provide an extra Exception to be thrown seems not what the specification wants...

I could, ofcourse, use the Adapter pattern to provide a similar interface to the client...

(It is an interesting discussion with myself, but I wouldn't mind if somebody joined )
 
mike acre
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read this currently active thread

It is discussing this issue in detail.

Your interface structure for combining local & network modes is crucial in simplifying this problem.
 
Marlene Miller
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is an interesting discussion with myself, but I wouldn't mind if somebody joined.


Please join us Noel on the other thread.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!