This content has been marked as final. Show 3 replies
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 exceptionYou 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.
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.