aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes ApplicationException, when handled Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "ApplicationException, when handled" Watch "ApplicationException, when handled" New topic
Author

ApplicationException, when handled

Treimin Clark
Ranch Hand

Joined: Nov 12, 2008
Posts: 757
Imagine that "CreditException" is an @ApplicationException with the rollback=true element.



If the thrown exception is handled, as shown in the above code, do it cause the active transaction to be marked for the rollback?
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9349
    
    2

I feel the guy who started the transaction should receive the exception or else, the rollback will not happen. Ranchers, am I right?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
I don't think so. Because first it does not make sense, and second how the container knows that you handle an application exception? The container can know when an application exception is thrown, but it is too much to know detail inside a method that what is going on.


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Raf Szczypiorski
Ranch Hand

Joined: Aug 21, 2008
Posts: 383
The exception must be thrown by a business / listener method or its interceptor, the container can then intercept it, check its type and rollback attribute, and take proper action. When you catch it inside your method, consume and not rethrow further, is is as if it was never thrown - the container does not now anything about it.
Treimin Clark
Ranch Hand

Joined: Nov 12, 2008
Posts: 757
Raf Szczypiorski wrote:The exception must be thrown by a business / listener method or its interceptor, the container can then intercept it, check its type and rollback attribute, and take proper action. When you catch it inside your method, consume and not rethrow further, is is as if it was never thrown - the container does not now anything about it.


Thanks Raf! Nice explanation.
 
Don't get me started about those stupid light bulbs.
 
subject: ApplicationException, when handled