Originally posted by Peter Warde:
I know it's legal for a implemented method of an interface to throw the same, subclass of or less exceptionsand I think the bean should never throw a Remote exception (because it is never remote, only the Remote Component and Remote Home interfaces are) but why does the interface have them if the bean doesn't need them or vice versa?
Thanks.
Only the Remote Interfaces need to declare RemoteException exceptions and the reason is quite straight forward: the interfaces (home and component) expose the contract that the client uses to invoke methods on the bean or on the home object and are implemented by the stub to the EJBObject and EJBHomeObject. Because the Home and Component interfaces give life to remote objects (because these extend java.rmi.Remote), each method defined in those interfaces need to declare java.rmi.RemoteException, even if you are writing a simple RMI application. It is a bad mistake to declare RemoteException from within the bean class, because this would limit the bean visibility to remote clients; on the other side, if you declare local views for your bean, it's an error to declare RemoteException in the business methods.
[ September 03, 2004: Message edited by: Marco Tedone ]
Marco Tedone<br />SCJP1.4,SCJP5,SCBCD,SCWCD