wood burning stoves 2.0
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes System Exceptions Doubt 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 "System Exceptions Doubt" Watch "System Exceptions Doubt" New topic

System Exceptions Doubt

Hiten Ravani

Joined: May 03, 2005
Posts: 8
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)


chao cai
Ranch Hand

Joined: May 26, 2005
Posts: 154
I do not think transcation of bean1 will be rollback,for different transcation context

SCEA<br />SCJP 1.2<br />SCBCD<br />MCSD<br />IBM Certified Specialist RUP v2003<br />IBM Certified Solution Designer OOAD vUML2<br /> <br />Phone Number:86-010-82776427
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8927

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

Joined: Feb 28, 2005
Posts: 30
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

Joined: Jun 07, 2004
Posts: 76
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

Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8927

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
� 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

Joined: Mar 09, 2005
Posts: 97
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.

[ September 21, 2005: Message edited by: Soni Prasad ]

SCJP 1.4, SCBCD 1.3
Valentin Crettaz
Gold Digger

Joined: Aug 26, 2001
Posts: 7610
WOuld my cheat sheet on bean exceptions help?

[Blog] [Blogroll] [My Reviews] My Linked In
I agree. Here's the link: http://aspose.com/file-tools
subject: System Exceptions Doubt
It's not a secret anymore!