Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RMI-cannot override interface methods

 
Glen Iris
Ranch Hand
Posts: 172
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am trying to figure out how to solve this problem:

The methods I am making available via RMI need to throw RemoteException. However, the methods that they overwrite do not throw RemoteException. I guess this is a fairly common problem encountered when coding B&S but I havent been able to find any documentation that has been of use.

Any thoughts?

g
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, Glen!

How about this one? I think it will be helpful to you!
 
Glen Iris
Ranch Hand
Posts: 172
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Roberto,

I think that is a step ahead of where I am. I cannot figure out how DennysDVD's gets around the problem. Put simply:

How can the methods in DvdDatabaseRemoteImpl throw RemoteException when the methods they are overriding (those which exist in DBClient) do not throw this exception?

g
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you should have a look at the inheritance tree of RemoteException. It will certainly clear your doubts
 
Glen Iris
Ranch Hand
Posts: 172
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahhhh. Got ya.

It still leaves me without a solution for the bigger picture .

So I get to write the exceptions that the sun provided interfaces' methods throw. So I guessed that if I made them extend RemoteException then I would have solved my problem. But I am still coming up with the following error when i try to run my Server:
java.lang.IllegalArgumentException: illegal remote method encountered: public abstract void suncertify.db.DBMain.lock(int) throws suncertify.db.RecordNotFoundException


From research, it seems that the error is occuring because the methods I am exposing via RMI do not throw the RemoteException. Maybe I am wrong on that one?
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I guessed that if I made them extend RemoteException then I would have solved my problem.

That's simply a bad design! You should only use inheritance if you have an IS-A relationship between 2 classes, not because it's convenient. And because RecordNotFoundException is not a RemoteException using inheritance is not the way to go.

Maybe I am wrong on that one?

Just create an own business service interface where each method throws RemoteException. Here you decide between a thick or thin client approach.

Here you'll find more info about the do's and don'ts about RMI (& RemoteException).
 
Glen Iris
Ranch Hand
Posts: 172
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Roel. I'll check it out.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic