Muthu,
Thanks for posting a good question.
HFEJB mentions that
'setting rollbackonly' and getting the status of rollback(CMT) cannot be done in ejbCreate (thro' SessionContext) whereas these operations could be performed using 'UserTransactions' in BMT.
You can call the getUserTransaction() method in ejbCreate(), for both Stateful & Stateless session beans
(BMT beans only). The return type of this method will be an object of type UserTransaction.
Only for Stateful session beans(BMT), in ejbCreate(), you can access UserTransaction methods, but not all the methods. UserTransaction methods are not avaible in session beans, since there is no client associated with the bean, during creation.
The Spec says (Pg- 81):
Additional restrictions:
The getRollbackOnly and setRollbackOnly methods of the SessionContext
interface should be used only in the session bean methods that execute in the context of a transaction.
The Container must throw the java.lang.IllegalStateException if the
methods are invoked while the instance is not associated with a transaction.
So it is confirmed that you cannot call setRollBackOnly() methods in ejbCreate(), irrelevant of whether the bean is stateful/stateless or CMT/BMT.
You can refer the tables in page 80 & 90 of the spec.