3 Replies Latest reply: Jan 26, 2012 5:53 PM by EJP RSS

    catching rmi serverException

    913277
      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
          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
            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
              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.