• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

RMI-cannot override interface methods

 
Ranch Hand
Posts: 175
Netbeans IDE Chrome Java
  • 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
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • 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: 175
Netbeans IDE Chrome Java
  • 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
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • 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: 175
Netbeans IDE Chrome Java
  • 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: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • 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: 175
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Roel. I'll check it out.
 
what if we put solar panels on top of the semi truck trailer? That could power this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic