A container may only passivate a session bean instance when the instance is not in a transaction.
If I am not mistaking, this applies to session beans with bean managed transaction demarcation only. Because I think in case of CMT the transaction will not remain open before leaving the method - is this correct?
Yes you're correct. BMT is a way to allow beans to manage their transactions by themselves, and especially one aspect of the transaction : it's scope. The scope for CMT tx is the method in which it runs, which means from method start to method end. But BMT allows bean to make smaller and (in case of stateful session beans) longer transactions.
So yes, you're correct.
One thing to keep in mind about BMT, and which is not very much tested (but might be in real exam) : BMT beans do not accept tx from outside, they only use tx they initiated. Off topic here, but while I'm thinking about this, I say it .
Good point that one ... Actually I had posted a separate question on this. The question was that - when we say BMT beans do not accept tx from outside - are we talking about the bean scope here or the method scope here? And the reply I got was the bean scope. So I interpret it as a BMT transaction started in one method of the BMT can propogate in the other method of the same BMT bean.
I think this will apply for session bean's with cmt also. For example Bean A's method funA (has tx attribute Required) is invoking funB(has tx attribute Required) in Bean B.Now even after executing funB it's transaction is not yet over.It has to commit or roll back(This depends on funA of Bean A).In this case i think Bean B will not be passivated.
No, after funB() method is over, tx only covers bean A; bean B is not in any transaction anymore at this time, so it may be passivated. Bean A will not be passivated until completion of tx, but bean B is not protected, as it didn't initiate tx; it appeared during tx lifetime, that's all.