
You've hit on my biggest pet peeve with RMI - lack of location transparency. I haven't found a solution that I would consider elegant. What I've done in the past is declare an interface that is identical to my remote interface EXCEPT for the RemoteException declarations. The actual business object implements this interface. In local usage, the client accesses the BOs directly through this interface. In remote usage the client uses a proxy that implements this interface and wraps the actual remote proxy, catching RemoteExceptions and wrapping them as either application specific exceptions or RuntimeExceptions as appropriate and rethrowing them. The proxy might also implement some kind of retry logic. I usually use some kind of factory in the client that vends the correct type of proxies as required.
This approach has worked for me, but I don't really like it. You end up with the duplicate interface declarations that need to be kept in sync and it just generally messy. Another option would be to consider an alternative like the Apache Jakarta AltRMI project (
http://incubator.apache.org/projects/altrmi/)which is designed to be an RMI replacement with better transparency. I haven't used it, but it looks promising.
HTH!
Eddie
"When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon. You just have to outrun the halfling."