About Question enthuware.oce-ejbd.v6.2.451 :
Moderator: admin
-
- Posts: 54
- Joined: Tue Apr 19, 2011 10:32 am
- Contact:
About Question enthuware.oce-ejbd.v6.2.451 :
An observation for D: As the Javadoc says, an EJBTransactionRolledbackException may mean that the TX has been rolled back, or marked for rollback. So you can't know for certain that "the transaction has been marked for rollback". it may have been rolled back already.
-
- Site Admin
- Posts: 10386
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.451 :
This has been updated. Thanks for your feedback!
-Paul.
-Paul.
Re: About Question enthuware.oce-ejbd.v6.2.451 :
Why the answer:
"If the client receives EJBException, it can assume that the transaction will never commit." is not true? Because there may be no transaction at all?
"If the client receives EJBException, it can assume that the transaction will never commit." is not true? Because there may be no transaction at all?
-
- Site Admin
- Posts: 10386
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.451 :
As the explanation says, "EJBException does not tell anything about the status of the transaction. If the client executes in the context of a transaction, the client’s transaction may, or may not, have been marked for rollback by the communication subsystem or target bean’s container."jszczepankiewicz wrote:Why the answer:
"If the client receives EJBException, it can assume that the transaction will never commit." is not true? Because there may be no transaction at all?
This can happen when the caller's transaction is not same as the called method's transaction (e.g. in case of RequiresNew). In this case, if the caller receives EJBException, you cannot be sure that the caller's transaction has been marked for rolled back.
HTH,
Paul.
-
- Posts: 429
- Joined: Tue Jul 24, 2012 2:43 am
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.451 :
To my understanding the transaction has not been rolled back, the container has only marked the transaction for rollback just before throwing an EJBTransactionRolledbackException to the clientAn observation for D: As the Javadoc says, an EJBTransactionRolledbackException may mean that the TX has been rolled back, or marked for rollback. So you can't know for certain that "the transaction has been marked for rollback". it may have been rolled back already.
This is what the specifications say:
Regards,14.4.2.1javax.ejb.EJBTransactionRolledbackException, javax.ejb.TransactionRolledbackLocalException, and javax.transaction.TransactionRolledbackException
If a client receives one of these exceptions, the client knows for certain that the transaction has been marked for rollback. It would be fruitless for the client to continue the transaction because the transaction can never commit.
Frits
-
- Site Admin
- Posts: 10386
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.451 :
I think a transaction that has been rolled back will satisfy the test for a transaction that has been marked for roll back. So it is certain that a transaction has been marked for roll back (as the specification says), on top of it, the transaction might have been rolled back as well (as the javadoc says). The name of the exception also indicates that the roll back might have happened already.fjwalraven wrote:To my understanding the transaction has not been rolled back, the container has only marked the transaction for rollback just before throwing an EJBTransactionRolledbackException to the clientAn observation for D: As the Javadoc says, an EJBTransactionRolledbackException may mean that the TX has been rolled back, or marked for rollback. So you can't know for certain that "the transaction has been marked for rollback". it may have been rolled back already.
This is what the specifications say:Regards,14.4.2.1javax.ejb.EJBTransactionRolledbackException, javax.ejb.TransactionRolledbackLocalException, and javax.transaction.TransactionRolledbackException
If a client receives one of these exceptions, the client knows for certain that the transaction has been marked for rollback. It would be fruitless for the client to continue the transaction because the transaction can never commit.
Frits
What do you think?
-
- Posts: 429
- Joined: Tue Jul 24, 2012 2:43 am
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.451 :
I am not sure whether that is true, because I doubt that you can still do the test..I think a transaction that has been rolled back will satisfy the test for a transaction that has been marked for roll back.
I have checked all places in the specs and the only places that the container throws an EJBTransactionRolledbackException is when the bean instance is executing in the client’s transaction (and it then marks the transaction for rollback)
14.3.1 Exceptions from a Session Bean’s Business Interface Methods and No-Interface
14.3.7 Exceptions from Other Container-invoked Callbacks
In all the other cases, when the transaction is rolled back by the container, an EJBException is thrown to the client.
My conclusion, based on the specs is that the API is not entirely correct here.
Regards,
Frits
-
- Site Admin
- Posts: 10386
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.451 :
Do you mean if you call getRollbackOnly() on a Transaction that has been rolled back, it will return false?fjwalraven wrote:I am not sure whether that is true, because I doubt that you can still do the test..I think a transaction that has been rolled back will satisfy the test for a transaction that has been marked for roll back.
That really doesn't make sense.
-
- Posts: 429
- Joined: Tue Jul 24, 2012 2:43 am
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.451 :
I think that getRollbackOnly(), according to the API, will return false on a rolled-back transaction.Do you mean if you call getRollbackOnly() on a Transaction that has been rolled back, it will return false?
That really doesn't make sense.
Regards,getRollbackOnly
boolean getRollbackOnly() throws java.lang.IllegalStateException
Test if the transaction has been marked for rollback only. An enterprise bean instance can use this operation, for example, to test after an exception has been caught, whether it is fruitless to continue computation on behalf of the current transaction. Only enterprise beans with container-managed transactions are allowed to use this method.
Returns: True if the current transaction is marked for rollback, false otherwise.
Frits
-
- Site Admin
- Posts: 10386
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.451 :
Frits, I guess you are right. Can't really argue much with the Specs or API 

-
- Posts: 358
- Joined: Fri Nov 29, 2013 8:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.451 :
The API at http://docs.oracle.com/javaee/6/api/jav ... ption.html
says
But according to the API, this transaction indicates the transaction started by the client has been rolled back or is marked as rolled back.
Another notes for everyone, based on my understanding:
getRollbackOnly() = true indicates that a transaction has been marked for rollback.
But if the transaction has been rollback, the getRollbackOnly() = false.
says
So, according to the JSR 318, EJBTransactionRolledBackException indicates that the transaction started by the client, is marked as rolled back.This exception is thrown to a remote client to indicate that the transaction associated with processing of the request has been rolled back, or marked to roll back.
But according to the API, this transaction indicates the transaction started by the client has been rolled back or is marked as rolled back.
Another notes for everyone, based on my understanding:
getRollbackOnly() = true indicates that a transaction has been marked for rollback.
But if the transaction has been rollback, the getRollbackOnly() = false.
Who is online
Users browsing this forum: No registered users and 5 guests