what happens if System Exception occurs from a method in a session bean in EJB 3.0?

StackOverflow https://stackoverflow.com/questions/20836594

  •  22-09-2022
  •  | 
  •  

سؤال

What happens if a system exception occurs from a method in a session bean that has a transaction attribute REQUIRED_NEW and this method is called by some other method which is running in other transaction (i.e REQUIRED).

Transaction

Will the suspended transcation(i.e Required) rollback or not ??

هل كانت مفيدة؟

المحلول

what happens if System Exception occurs from a method in a session bean in EJB 3.0?

This is what the ejb3 specification says:

14.2.2 System Exceptions

... The container catches a non-application exception; logs it; and, unless the bean is a message-driven bean, throws the javax.ejb.EJBException.

... The transaction in which the bean method participated will be rolled back....

and the bean instance will be discared.

Will the suspended transcation(i.e Required) rollback or not ??

In your case the Client method runs in a different transactional context, therefore, if you catch the javax.ejb.EJBException that was originated in the target bean, the transaction will commit. Otherwise, the transaction will be rolled back.

نصائح أخرى

If you don't handle exception inside method A, exception will throw higher and rollback bought transactions.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top