• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

System Exceptions Doubt

 
Hiten Ravani
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a doubt regarding system exceptions. I will try to give you a scenario:

Say Method-1 (Required) ---> Method-2 (Non-supported)

If Method-2 were to throw a system exception will the transaction started by method 1 but suspended currently be rolledback or not ?

Would there be any difference if Method-2 was in the same bean or another bean??

What happens if the scenarios chages to :

Method-1 (Required) ---> Method-2 (Requires-New)

Thanks

Regards,
Hiten.
 
chao cai
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not think transcation of bean1 will be rollback,for different transcation context
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by chao cai:
I do not think transcation of bean1 will be rollback,for different transcation context


But the method1 would receive the exception and I am assuming that method1 does not catch it so it will result in expection being propagated so the rollback should happen? :roll:
 
ashok kumar
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
The transaction of method A won't rollback.Bcoz the transaction of method a is suspended when it goes to method B in both the case.But if both the methods are in same Bean then the transaction will be rollbacked and the instance will be killed.
 
Adri Smith
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not know if anybody is willing to continue this thread but I really do think the question is relevant. In my sense the transaction existing in the method 1 should be "rollbacked" if bean1 is local (even if the transaction has been suspended by the method2's call). If the bean1 is remote it will depend of the catch clause.

If anybody can confirm me, it will be grateful

Thx,
Adri
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The container catches a non-application exception; logs it (which can result in alerting the System
Administrator); and, unless the bean is a message-driven bean, throws the java.rmi.RemoteException
(or subclass thereof) to the client if the client is a remote client or web service client, or
throws the javax.ejb.EJBException (or subclass thereof) to the client if the client is a local client.
In the case of a message-driven bean, the container logs the exception and then throws a
javax.ejb.EJBException that wraps the original exception to the resource adapter. (See [12]).
The Bean Provider can rely on the container to perform the following tasks when catching a non-application
exception:
� The transaction in which the bean method participated will be rolled back.
� No other method will be invoked on an instance that threw a non-application exception.
This means that the Bean Provider does not have to perform any cleanup actions before throwing a
non-application exception. It is the container that is responsible for the cleanup.
 
Soni Prasad
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Adri,
I agree with your thinking as I also think that if an EJB throws a system exception container will catch it and throw the RemoteException or EJBException which the client will recieve, now if the client itself is an EJB it will also rethrow as it may not be catching it so this recieving EJB should also be removed by the container as it is throwing a system exception and its transaction should be rolled back.

soni.
[ September 21, 2005: Message edited by: Soni Prasad ]
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
WOuld my cheat sheet on bean exceptions help?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic