Thanks David. On Wed, Mar 18, 2009 at 6:23 PM, David Blevins <[email protected]>wrote:
> On Mar 18, 2009, at 1:21 PM, Karan Malhi wrote: > > Section 4.4.3 (Missed Destroy Calls) of EJB 3.0 spec says that if >> >> *A system exception thrown from the instance’s method to the container, >> then >> @PreDestroy would not be called* >> >> Could somebody explain what could be the reason behind not choosing to >> call >> @PreDestroy? To me it looks like a very natural candidate for @PreDestroy. >> > > Destroying beans that throw runtime exceptions is not something about EJB > I'm fond of in general. > > That said if you're on board with the concept that a bean that has thrown a > runtime exception is invalid you really don't want to keep invoking it in > the scope of the current transaction. > > For stateful session beans, when they time out they are destroyed -- or > perhaps more accurately phrased, never brought back into memory -- and the > PreDestroy method is also not called. > > For general consistency the rule is @PreDestroy is not called on an invalid > bean. > > -David > > -- Karan Singh Malhi
