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

Related Questions

I still very new using Subversion. Is it possible to have a working copy
Maybe this is a very silly question but I'm new using django. I have
New at using admob within Android. Is it possible to show ads with certain
Very new to using Raphael.js I'm looking at the tutorials and I am able
I'm new to using PDO and have got a little bit stuck- is there
I have built a variety of little scripts using Ruby's very simple Queue class,
Im new using Python, now I have a problem using ElementTree and read out
Is it possible to get the memory usage statistics of a tomcat server using
I'm new using CXF and Spring to make RESTful webservices. This is my problem:
I have two applications communicating via RMI, a slave server (of which there will

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.