From which method in a stateless session bean can the begin method be called?
A. the setSessionContext method in a CMT demarcated bean B. the ejbRemove method in a BMT demarcated bean C. a business method in a CMT demarcated bean D. a business method in a BMT demarcated bean
I suspect that the being method being called is the one declared in the javax.transaction.UserTransaction interface. If this is the case, then A and C can be eliminated because CMT beans cannot use the UserTransaction interface. Then since we are talking about stateless session beans, only answer D makes sense as BMT session beans can only use the UserTransaction interface in their business methods and not in their ejbRemove method. (Table 3, page 90 of the spec)
Note: if we were talking about stateful session beans, the story would be different as answers B and D would be both correct (Table 2, page 80 of the spec)
The spec says that stateless sbean ejbCreate/ejbRemove() can look up the UserTransaction but not to call methods on it.
But, what is the rationale behind the difference? It seems that this is the only place where the rule for look up UserTransaction is 'decoupled' from calling UserTransaction methods.
It seems that this is the only place where the rule for look up UserTransaction is 'decoupled' from calling UserTransaction methods.
The same happens in ebjCreate/Remove of MDB. I find this annoying too, I don't understand why you are able to look it up if you can't use it. Does anyone know what the story is here? I have the feeling it's one of those the-spec-says-so things ...
This is one of the questions in the sun practice exams. It says answer is D, which makes sense. Even though you have the sessionContext reference, only you can call non-transaction related methods. Since they all throw IllegalStateException when called in a non tx method and all the SessionBean interface run in unspecified Tx, it can only be business method in BMT.
Everybody! Do the Funky Monkey! Like this tiny ad!
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth