Originally posted by Vish Kumar:
How about the list of application exceptions declared in the method signatures? I read somewhere that they are not required to match...
Am I right?
hi, Vish
At least I did not read in spec that list of throwable exceptions for ejbCreate and ejbPostCreate has to be the SAME,
so...
I could guess that they may have declare different exceptions in their signatures...
But how to hanle this situation... Client call "create()" method and as a result Container call ejbCreate + ejbPostCreate both methods on bean class. What happens if something bad happens in ejbCreate ? or ejbPostCreate ?
What spec says about this (page 195):
All the exceptions defined in the throws clause of the matching ejbCreate<METHOD> and ejbPostCreate<METHOD> methods of the enterprise Bean class must be included in the throws clause of the matching create method of the home interface (i.e., the set of exceptions defined for the create method must be a superset of the union of exceptions defined for the ejbCreate<METHOD> and ejbPostCreate<METHOD> methods).
The throws clause of a create<METHOD> method must include the javax.ejb.CreateException.
As we can see, ejbCreate and ejbPostCreate MAY have different list of application exceptions in throws definition, but all of them must present in "create()" declaration, because container would like to be prepared for something bad happened both in ejbCreate and ejbPostCreate.
Some note about "create()" method...
"create()" has to have : all exceptions declared in "ejbCreate()" +
all exceptions declared in "ejbPostCreate()" +
RemoteException (Remote view only) + CreateException (even if it is not declared for ejbCreate() or ejbPostCreate())
Think of "ejbCreate()" (or "ejbPostCreate()" ) as a BOSS (you see it has a CAPITAL letter in his name, so he IS a boss, and boss is free to declate CreateException or no; but "create()" - is a regular employee, it even has all it's name in lowercase, so he has no choice and it has to declare CreateException always).
Cheers
