• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Usage of XA DataSource while working with single resource.

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an MDB(Bean Managed Transaction) which calls method on a helper class to do following activities when activated.
1. It does some Database Activity using an XADataSource. This activity doesn't give any error.
2. When same XA DataSource is used inside a User Tannsaction. It gives me following exception
Error : Cannot begin a LocalTransactionContainment. A LocalTransactionContainment is already active.
[1/16/03 21:57:40:203 IST] d97d42c LocalTransact E J2CA0024E: Method rollback, within transaction branch ID <null> of resource pool jdbc/SBMCommonDB, caught com.ibm.ws.exception.WsException: DSRA0080E: An exception was received by the Data
Store Adapter. See original exception message: Use explicit XA call.
However It works fine when
1) I comment out first activity second activity works fine
2)when I use diffrent datasources for both the activities.(for first I used non XA Datasource, and for second I used XADataSource)
Can Someone expalin why it happens.
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you using CMT on your MDB, and if so, what is it set to? (I'm guessing NOT_SUPPORTED right now...)
Kyle
 
Subhash Namboodiri
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kyle,
The MDB is having transaction as Bean Managed. The total activities done are
Step 1. Few database activity before starting UserTransaction.
Step 2. UserTransaction is started and few database and JMS activities are being done.
Step 3. UserTransaction is stopped.
All these activities are done using a XADatasource and TCF of XA type. In such situation when performing the Step 2 (starting the UserTransaction) the following error is thrown:
Error : Cannot begin a LocalTransactionContainment. A LocalTransactionContainment is already active.
Now, if only Step 2 is performed without performing Step 1, it works fine.
Also if Step 1 is done using a NonXA datasource and Step 2 is done using XA Datasource it works fine.
I think the Transaction properties like "Required", "NotSupported" etc is not significant if we use Bean Managed Transaction, am I right?
Now in such situtations is it required to use two datasources - one NonXA and one XA type ?
Subhash
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cool! This just happens to be an example of what I'm writing about in my book as we speak. Now that I understand your problem, I think I can suggest a solution.
What you want to do is to force the "local transaction" that happens outside of the UserTransaction to complete BEFORE you begin the UserTransaction, right? You see, the problem is that it hasn't, so that's why things blow up for you. I believe (I'd have to try this to be sure, but this sure sounds like a good test to try!) that you could solve your problem in the following way:
(1) Create a "Worker" Session bean that your MDB calls to do the work. It just has to have a Local Interface, no need for a Remote Interface.
(2) Have the "Pre User Transaction" work done all in one method of the "Worker Session". Let's call that "doEarlyWork()"
(3) Put all the rest of the work in another method of the "Worker Session". Call that "doLaterWork()".
Now let's talk about settings. For the MDB, I think that either "Bean Managed" or "Supports" would work for the transaction setting. For the "Worker Session", though, you need to set the "doLaterWork()" to "Bean Managed", as you have now, but you can set the "doEarlyWork()" method to (I think) either "Supports" or "Bean MAnaged".
Finally, on the "Worker" bean, set the "Local Transactions 2.0" settings to:
Boundary: Bean Method
Resolver: ContainerAtBoundary
UnresolverAction: Commit.
What that should do is to force the Local transaction started in "doEarlyWork" to commit properly before the UserTransaction is started.
If I get a moment, I'll try this on my own, but I'm reasonably sure this should work. If my test doesn't work out, I'll post a corrected version. Likewise, if this doesnt' work for you, I hope you'll post what happens!
Kyle
 
We can walk to school together. And we can both read this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic