Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB Transaction Problem :confused:  RSS feed

 
syed mraza
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks
Enviroment: EJB1.1, Weblogic6.0 sp2
i've a session bean's method calling 2 BMP (bean-managed persistance) entity bean.
the transaction type in teh session bean is "container-managed" and the
transaction attribute is "Required" in all the the calling method. the code
goes like this

now with all these setting should there occurs an error in myBMP2.create()
the queries inserted in myBMP1.create() should revert back too. But since
this is not a perfect world this is not happeneing even though the
session Beans EJBContext.getRollbackOnly() is (automaticaly)set to "true"
after error in myBMP2.create()
any help/suggestion/thought would be realy appriciated
rgds
 
Kirt Henrie
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Syed,
I am not familiar with Weblogic, but here are some things to check.
Make sure you are specifying the entity bean(s) create method transaction type as required or mandatory to insure that they are participating in the transaction.
Also, in the exception block on the session bean method, try explicitly setting the rollback (EJBContext.setRollbackOnly()), or throwing an EJBException (throw new EJBException(e)). Either of these two actions should cause a rollback.
KJ
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's my guess. During a customer performance test we once had a customer find out that WebLogic does not involve EJB create methods in an existing outer transaction -- basically the INSERT statement is in its own transaction.
This (of course) resulted in having the same test run faster in WebLogic than WebSphere (which does involve create() methods in the outer transaction). We then carefully read the EJB spec and found out that it is ambiguous on this point. Either way is OK. Is it what you would expect? Probably not. Is it spec compliant? Well, it appears so...
Kyle
 
michael huang
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is because of weblogic's connection default property, you can see weblogic's Connection autoCommit is true
you should set it false
, yes i think this is they want to get a perfect benchmark
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!