There is no method to determine this information directly. However, you can get at the information indirectly by relying on the fact that EJBContext.getUserTransaction throws an exception for CMT:
@Resource EJBContext ejbContext;
private boolean isBeanManagedTransaction() {
try {
ejbContext.getUserTransaction();
return true;
} catch (IllegalStateException e) {
return false;
}
}
Note, the getUserTransaction method cannot be called from all container callbacks (see the table of allowed operations in the EJB spec), but fortunately, getUserTransaction can be called from ejbCreate/PostConstruct, so this method should work for your purposes.