Hi,
I am using Session Facade pattern where Stateless Session Beans interact with CMPs. I have set the Transaction Attribute for both Stateless Session Bean and CMP as "Required". My problem is, if I get any exception in Stateless Session Bean method, transaction is not getting rolled back. That is, I have a requirement of updating two tables from a Session Bean. So I am calling my 1st CMP from my session bean. After that I have some code for implementing Business Logic which gets excuted. Then I am calling 2nd CMP for updation. But if I get any exception in Business Logic implementation, the 1st CMP's updation to DB doesnot get rolled back. It gets committed. Is there anything I have missed out? Do I need to use XA connection pool for transactions? Please let me know.
Thanks
Prasanna
-
Session Facade Transaction (6 messages)
- Posted by: Prasanna K
- Posted on: March 16 2004 01:03 EST
Threaded Messages (6)
- session facade by Manish Mudgal on March 16 2004 23:43 EST
- session facade by Prasanna K on March 17 2004 01:05 EST
-
session facade by Mauro Ramon on March 17 2004 05:43 EST
-
session facade by Prasanna K on March 17 2004 09:38 EST
-
session facade by Mauro Ramon on March 17 2004 10:49 EST
- session facade by Prasanna K on March 18 2004 07:20 EST
-
session facade by Mauro Ramon on March 17 2004 10:49 EST
-
session facade by Prasanna K on March 17 2004 09:38 EST
-
session facade by Mauro Ramon on March 17 2004 05:43 EST
- session facade by Prasanna K on March 17 2004 01:05 EST
-
session facade[ Go to top ]
- Posted by: Manish Mudgal
- Posted on: March 16 2004 23:43 EST
- in response to Prasanna K
Hi,
Are you calling both the methods of CMP in same method of session bean?,if you are doing so then it should work,If you are caling in different methods then every time it will open new transcation.
Regards,
Manish -
session facade[ Go to top ]
- Posted by: Prasanna K
- Posted on: March 17 2004 01:05 EST
- in response to Manish Mudgal
Hi,Are you calling both the methods of CMP in same method of session bean?,if you are doing so then it should work,If you are caling in different methods then every time it will open new transcation.Regards,Manish
Yes, I am calling both the methods of CMP in same method of Stateless Session Bean. I am using JBOSS 3.0.6. Should I use XA connection pool? I am bit confused. Please help me.
Thanks,
Prasanna -
session facade[ Go to top ]
- Posted by: Mauro Ramon
- Posted on: March 17 2004 05:43 EST
- in response to Prasanna K
Are you doing setRollbackOnly() on SessionContext when you catch the Exception??? -
session facade[ Go to top ]
- Posted by: Prasanna K
- Posted on: March 17 2004 09:38 EST
- in response to Mauro Ramon
No,
Can u please let me know how to handle that Exception? I just want the transaction to get rolled back in case of any exception. Could please help me.
Thanks in Advance,
Prasanna -
session facade[ Go to top ]
- Posted by: Mauro Ramon
- Posted on: March 17 2004 10:49 EST
- in response to Prasanna K
public class LossFacadeEJB implements SessionBean {
private SessionContext sc = null;
public void ejbCreate() {
}
public void setSessionContext(SessionContext sc) {
this.sc = sc;
}
protected ResponseObject perform(Event event) {
ResponseObject response = null;
try {
entity1.doSomething();
entity2.doSomething();
} catch (Exception e) {
// Si se genera una excepcion se setea para rollback
sc.setRollbackOnly();
e.printStackTrace();
response = new ResponseObject("Error");
}
return response;
}
} -
session facade[ Go to top ]
- Posted by: Prasanna K
- Posted on: March 18 2004 07:20 EST
- in response to Mauro Ramon
Yes, it worked. Thank You very much!!!
Regards,
Prasanna