File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTA TRANSACTION-BEAN MANAGED TRNSACTION, NO ROLLBACK

 
ganesh jadhav
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi All,

I have a stateless session bean, with bean managed transaction.
the code is like this...
doTask()
{
try
{
utx=getUserTransaction();
utx.begin();

method1(); //in this i am updating few table in DB -DB connection is taken in the same method and closed there
method2(); // calling a stored procedure to do smthing etc
method3(); //update smthing else

utx.commit();
}catch(Exception y)
{
utx.rollback();
}

}

in all method1(), method2(), method3() , i have taken DB connection from Connection pool and closed in those methods only,

I am not using anything like connection.setAutocommit(false/true), in anywhere in the code.

if method3() goes down then it should rollback the db changes made in the method1 and method2.??? But it does not rollback the txn properly.

Is there any other way, I am stuck and can not go for
JDBC transactions at this stage, since i will have to do a lot of changes.

The application is on weblogic10 mp1.

Please let me know the reasons for the failure for the rollback.





 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

if method3() goes down then it should rollback the db changes made in the method1 and method2.??? But it does not rollback the txn properly.

So...what does it do? Rollback nothing at all?

 
Reza Rahman
author
Ranch Hand
Posts: 580
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ganesh,

Are these methods doing their own BMT also? If so, that would be the cause of the problem. BMT transactions do not join existing transactions. Also, what is the need for BMT at all?

Hope it helps,
Reza
 
ganesh jadhav
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its' not rollbacking anything at all.

Is there any problem in using BMT???

 
Reza Rahman
author
Ranch Hand
Posts: 580
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ganesh,

As I mentioned, BMT transactions do not participate in any existing transactional contexts (we talk about this in the book). If you are using BMT in *all* your methods, there would not be a "global" rollback. Also, BMT should be used only when CMT is not sufficient. Again, we talk about this in the book. Whatever reference you are using should be doing the same, so I would take a look there first.

Regards,
Reza
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic