• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

1-phase error in Websphere

 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got this in an email. I thought I'd drop it here so it can be discussed...


Dave,

I was reading your recent post re.. transactions in WAS/WSAD 5.0. I've worked with WAS for several years, but have never had to worry about transactions: the defaults seemed to take care of them.

I'm now doing a simple transactiion that involves two tables but am getting the following error: An illegal attempt to use multiple resources that have only one-phase capability has occurred within a global transaction.

I was hoping you might be able to point me in the right direction. Here are the specifics:

1) I have a stateless session bean in which I call two methods in an intervening mapper class. In a catch statement for Exception, I set mySessionCtx.setRollbackOnly();

2) the first call creates a bmp ejb (and, thus, a row in the DB2). It works correctly and returns without problem. ( I can see the row in the db wehn running in the debugger.)

3) the second call creates a cmp ejb. It crashes on the create with the message shown above. After that, the row in the first table is rolled back, as I would expect.

4) I have left the default transactions setting on the deployment descriptor for the session at the default: Required.

5) I have tried several settings on the cmp ejb, including Supports.

Can you point me in the right direction for setting up a simple transaction like this that invovles two operation on two different tables, one using a bmp bean and the other a cmp bean?

Specifically,
1) do I need to include any specific lines in my code for any of the ejbs?

2) What settings need to be set on the deployment descriptor(s)?


If its complaining about lack of support for the 2-phase protocol, it sounds like you're using the wrong DB2 Driver. Have a look at your DataSource and see if it uses the XA complient Driver or not. (I think the XA Driver is called DB2XADriver and is in db2java.zip, but I can't find it at the moment...)
Dave
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Dave. I now have a gen-u-wine 2-phase seesion ejb that in the same method can create instances of two different entity beans. All works fine now (e.g., no throuwn exceptions as described in original message) when both beans are successfully created. However, I'm getting exceptions during the rollback. I suspect I need to do something in my bmp ejb in ejbLoad and/or ejbStore, but I'll work on that.
In the meantime, I'll pass on a couple of things I have learned re. the "db2xadriver."
1) I don't think there is any such beast. I believe at the driver level it using the same "universal db2driver." What it seems to need is a set of XA classes including DB2XAResource DB2XADataSource and DB2XAConnection classes which are in the db2java.zip file.
2) The critical missing step is to define a new XA JDBC Provider and datasource objects. (I created a new Test Server and configuration to keep it separate from the 1-phase version.) Then, going to the Data Soruce tab for the new server, I created a new JDBC Provider, selecting COM.ibm.db2.jdbc.DB2XADataSource as the implementation class. I also added a new DataSource to be used with this provider.
Thanks for the pointer. On to the next problem!
john
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic