Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / June 2005

Tip: Looking for answers? Try searching our database.

override eroor

Thread view: 
Daniel - 17 Jun 2005 08:14 GMT
I want to implement rmi and get this error

test/PatientGui.java [151:1] getEnToonData() in test.PatientGui cannot
override getEnToonData() in test.ViewModel; overridden method does not throw
java.rmi.RemoteException

Public class PatientGui
 void getEnToonData() throws java.rmi.RemoteException
{

}

Public Class ViewModel

void getEnToonData()
  {
     System.out.println("Moet nog gemaakt worden in de sub-class");
  }

If i remove the throws java.rmi.RemoteException, the compiler tells me it
should be thrown.

How can i solve this?
Thanks

Daniel
Fred L. Kleinschmidt - 17 Jun 2005 15:50 GMT
> I want to implement rmi and get this error
>
[quoted text clipped - 22 lines]
>
> Daniel

Show us how you REALLY coded this, not the incomplete typing above (as
you show it here, there is no overridden method, since neither class
extends the other). As it is, we can only guess what mistakes you might
have made.

Signature

Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Common User Interface Services
M/S 2R-94  (206)544-5225

Dale King - 18 Jun 2005 02:42 GMT
> I want to implement rmi and get this error
>
[quoted text clipped - 19 lines]
>
> How can i solve this?

The issue is not specific to RemoteException, but with your design not
allowing for the possibility of unexpected behavior. Your ViewModel says
that it cannot throw a checked exception which RemoteException is and
that it must return data. What you need to think about is what is
supposed to happen if a subclass of ViewModel encounters a failure and
can't actually get the EnToonData?

Should it ignore any errors and return data anyway? This is usually not
desired, but if so you would have to catch the exception in the subclass
and return something.

Should it throw an unchecked (aka run-time) exception? In this case you
would catch the exception in the subclass and throw a runtime exception
(one that does not extend Exception). If you are using 1.4 or later you
would probably want to use the chained exception facility to point to
the RemoteException (see
<http://java.sun.com/j2se/1.5.0/docs/guide/lang/chained-exceptions.html>).

The most likely scenario is that your design should account for the fact
that this method can throw excpeptions and declare that the method in
ViewModel can throw a checked exception that users of that method have
to handle. This should not be RemoteException because that ties you to
RMI. You probably want to make your own exception class and declare that
it throws that. Your subclass would then do like the previous case
except that you use this exception class rather than the runtime exception.

Signature

 Dale King



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.