Hi Valentin,
I understand what you mean but I don't agree with you in a thing:
Originally posted by Valentin Crettaz:
...but they still have to declare the exception in the throws clause of their methods since your bean classes must implement the javax.ejb.EntityBean interface and/or the javax.ejb.SessionBean interface and RemoteException is a checked exception.
The fact that a method in an interface declares an exception
doesn't mean that the implementing method has to declare this exception (this is
SCJP ). What is true is that you must not declare any new checked exceptions for an implementation method.
I agree that according to the "Java law" it should work (for the moment, because it is
DEPRECATED) declaring the RemoteException , but what I can say for sure is that it is not mandatory. If you declare it (what I don't recommend since it is deprecated), it should be between square brackets. You can find lots of code to check what I say.
Besides, according to EJB 2.0 spec, section 18.3.8 (Support for deprecated use of java.rmi.RemoteException) the use of RemoteException in
"business methods, ejbCreate, ejbPostCreate, ejbFind<METHOD>, ejbRemove, and the container-invoked callbacks (i.e., the methods defined in the EntityBean, SessionBean, and SessionSynchronization interfaces)" is deprecated.
So if you declare RemoteException in ejbActivate, to be consistent,
you should do the same in every method mentioned in the last paragraph. But I really don't think that using deprecated expressions is correct (at least, without warning about it).
CONCLUSION: 1) I propose you
not to use any deprecated expressions, although they work for the moment, and
DELETE any reference to RemoteException in the bean classes. HFEJB also says this in pages 233 and 235:
"You MUST not declare RemoteException in your bean class, EVER." 2) ANY OTHER exceptions in the bean classes should be optional. This includes
CreateException in the ejbCreateMethods and
EJBException in all of the bean classes.
I hope that these suggestions will allow your cheat sheets, which are close to perfection, to get it.
[ April 27, 2005: Message edited by: Jose Esteban ]