aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes ApplicationException and rollback 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 and rollback" Watch "ApplicationException and rollback" New topic
Author

ApplicationException and rollback

Kiril Nugmanov
Ranch Hand

Joined: Jul 09, 2008
Posts: 42
Hi all,

I'm trying to execute following code:

Application exception with rollback set to true

Bean with method that catches application exception

After the thowException() method is executed, the status is returned as FALSE

But as I understand the transaction management - transaction should be marked as rollback. Am I correct


SCJP5, SCWCD5, SCBCD5, OCPJWSD5, OCMJEA 5
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Try to call the megaException() method from another bean. I don't think that the container is given a chance to rollback the transaction in your case.


[My Blog]
All roads lead to JavaRanch
Kiril Nugmanov
Ranch Hand

Joined: Jul 09, 2008
Posts: 42
Hi Christophe,

Tried as You said and obtained following results in log after calling megaException() from another bean:

According then it seems that I can't mark transaction as rollback if methods are from the same bean. It's strange or am I missing something
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

I don't find it strange. You're calling a method from the same bean, and catching the exception. The container cannot do anything in that case. You'd have to set the transaction for rollback yourself. If your thowException would also throw the exception, the container would get it, mark the transaction to be rolled back, and rethrow the exception to the client.
Kiril Nugmanov
Ranch Hand

Joined: Jul 09, 2008
Posts: 42
Thanks for clearing out.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ApplicationException and rollback