This discussion is archived
3 Replies Latest reply: Jan 26, 2012 3:53 PM by EJP RSS

catching rmi serverException

913277 Newbie
Currently Being Moderated
hi.

my server is throwing an exception that extends remote exception. as i understand this means that a rmi server exception is being created with my exception as it cause.

i want to catch this exception before it is being throwed and only throw my exception, since i dont want my client to see this the serverException, just my exception.

any thoughts on how to handle this problem?

thanks alot!!!!
  • 1. Re: catching rmi serverException
    EJP Guru
    Currently Being Moderated
    my server is throwing an exception that extends remote exception. as i understand this means that a rmi server exception is being created with my exception as it cause.
    No. It means that the server encountered either a RuntimeException or a RemoteException of its own, typically an UnmarshallException.
    i want to catch this exception before it is being throwed and only throw my exception
    You can do that in the case of a RuntimeException. Just add a try/catch block into your remote method body. In the other cases you can't, as they don't arise in your code.
    since i dont want my client to see this the serverException, just my exception.
    Again you've misunderstood. The ServerException doesn't wrap the exceptions that your remote method is declared to throw: it is one of the possible RemoteExceptions that your remote method may throw in addition to your own.

    It isn't clear from what you wrote, but if your 'my exception' extends RemoteException, that is a design mistake. Leave the RemoteExceptions for RMI and keep your own exceptions distinct.
  • 2. Re: catching rmi serverException
    913277 Newbie
    Currently Being Moderated
    yes, "my exception" extends another "my exception2" which extends remoteexception.

    so that is why a serverexception is being thrown?

    thanks for your reply
  • 3. Re: catching rmi serverException
    EJP Guru
    Currently Being Moderated
    so is that why a ServerException is being thrown?
    Please reread what I wrote above. I have already explained to you that it isn't, in some detail. What part of 'no' didn't you understand?

    I suggest you do two things:

    1. Don't have your own exceptions extend RemoteException. I have already said that too.
    2. Post the compete stack trace here.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points