In the book by Floyd, EJB Design Patterns, there is a great emphasis on making sure to execute "ctx.setRollbackOnly()" in an EJB exception caught clause before re-throwing an app exception.
Is this strategy applicable to Container Managed Transaction?
Yes, the strategy described above is also applicable for Container Managed Transactions. Infact by seeing the variable name 'ctx', I guess that the discussion was about CMT.
This is how you usually invoke 'setRollbackOnly()'
UserTransaction transaction = ejbContext.getUserTransaction();
transaction.rollback() (OR) transaction.setRollbackOnly();
Note that you dont have to do any of this if the exception is a system exception (i.e, not in the method's throws clause) and you are re-throwing it. In that case the container will rollback itself.
Yes, this strategy can applicable to CMP. One more thing you need note if you are using Bea Weblogic Server, you must using Tx Data Sources to connect it.