• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ApplicationException and rollback

 
Kiril Nugmanov
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Kiril Nugmanov
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for clearing out.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic