Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 148753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:00:53+00:00 2026-05-11T09:00:53+00:00

I am new to using RMI and I am relatively new to using exceptions.

  • 0

I am new to using RMI and I am relatively new to using exceptions.

I want to be able to throw an exception over RMI (is this possible?)

I have a simple server which serves up students and I have delete method which if the student doesn’t exist I want to throw a custom exception of StudentNotFoundException which extends RemoteException (is this a good thing to do?)

Any advice or guidance would be greatly appreciated.

Server Interface method

    /**  * Delete a student on the server  *   * @param id of the student  * @throws RemoteException  * @throws StudentNotFoundException when a student is not found in the system  */ void removeStudent(int id) throws RemoteException, StudentNotFoundException; 

Server method implementation

    @Override public void removeStudent(int id) throws RemoteException, StudentNotFoundException {     Student student = studentList.remove(id);      if (student == null)     {         throw new StudentNotFoundException('Student with id:' + id + ' not found in the system');     } } 

Client method

    private void removeStudent(int id) throws RemoteException {     try     {         server.removeStudent(id);         System.out.println('Removed student with id: ' + id);     }     catch (StudentNotFoundException e)     {         System.out.println(e.getMessage());     }  } 

StudentNotFoundException

package studentserver.common;  import java.rmi.RemoteException;  public class StudentNotFoundException extends RemoteException {     private static final long serialVersionUID = 1L;      public StudentNotFoundException(String message)     {         super(message);     } } 

Thank you for your reply I have now managed to fix my problem and realised that extending RemoteException was bad idea.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:00:54+00:00Added an answer on May 11, 2026 at 9:00 am

    It’s OK to throw any kind of exception (even custom ones), just make sure to package them up in your export .jar file (if you’re using a version of Java where you need to do this manually).

    I wouldn’t subclass RemoteException, though. Those are typically thrown if there is some kind of connection problem. Presumably, your client will handle connection problems differently from other types of problems. You might tell the user the server is down when you catch a RemoteException, or connect to a different server. For StudentNotFoundException, you probably want to give the user another chance at entering the student info.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 68k
  • Answers 68k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer There are two ways I would look at it: start… May 11, 2026 at 12:13 pm
  • added an answer Once you promote a machine to a Domain Controller, it… May 11, 2026 at 12:13 pm
  • added an answer 'The Admin is not your app.' If the customization goes… May 11, 2026 at 12:13 pm

Related Questions

I am fairly new to using infragistics controls (started yesterday). While they are (very)
I am relatively new to using jQuery and would like to use the load
I am new to Java and am trying to run a program using Eclipse.
I am new to visual studio/asp.net so please bear with me. Using vs 2005
I am new to Python, and I'm working on writing some database code using
I am new to Swing. I am trying to develop an application using Swing.
I'm kinda new to using Rails, and an app I am working on is
I'm new to development using Xcode, and am having trouble using the built-in Leaks
I am trying to create a new contact using Dynamic Entity. The sample i
I'm new to C#, and am curious about best practice for using namespaces. I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.