I have the same problem, like some other guys too.
I found a brand new 70 euros problem ticket at www.infutura.com dealing with exactly the same question.
I think we have to wait until it is solved there.
Solutions are free. To view solution proposals you have to be a member. But membership is free.
setRollbackOnly before throw your exception.
thanks, but i don't need to set setRollbackOnly, it rolls back correctly when i use bean-managed (my own) transactions as shown commented out.
i'm trying to avoid writing tx.commit() and tx.rollback() and tx.setRollbackOnly() in the first place. by setting my session bean to container-managed transactions.
What do you want to achieve?
If you want a CMT to be rolled back you also need to tell it so.
If an exception occours, fine. If your business logic decides to roll back - how should the container know this?
i thought the point of a container-managed transaction is that iether the entire thing commits, or the entire thing fails. Like that whole ATM example, getting $ and subtracting it from the account is one transaction. if error happens the whole thing does not happen -- it doesn't subtract money from your account without giving it to you -- it rolls back.
bascially what you're saying is that there is no such thing as a container managed transaction, even when ejb-jar.xml has a <trans-attribute>Required</trans-attribute>, i still need to manage transactions myself -- telling them when to start, commit, and roll back?
I tried to get a usertransaction in a contaniner-managed bean and Jboss told me "CMT beans are not allowed to get a UserTransaction"
so i using setRollBackOnly() or even rollBack() is not the solution to the container-managed transactions problem, because Jboss will not even let me access it in Container Managed Transactions.
my question is not about using UserTransaction (UserTransaction works in Bean-managed session beans but not, as shown, CMT) but about getting a container-managed transaction to roll back when it fails!
ok i get it...
i need to set setRollbackOnly () on the *SessionContext* when i catch exception.
i didn't see that method there...
it works now