• 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

Two-Phase commit Exception

 
Ranch Hand
Posts: 57
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I getting Two-Phase commit Exption in my application for one of the datasource. Point is application only does ready only data option using Oracle Toplink. Here is what happling in Application

1. Request come to webservice
2. Webservice calls to JMS Queue. Application need response from queue so used queue with Read Respose
3. In Message Bean( Lets call this ProcessBean), several successful hit goes to Oracle DB using Oracle Toplink, no exception is trown.
4. After DB data read pointer goes to call to Blaze rule RMI API provided by Blaze. we get successful result.
5. Queue Calles Response Queue and Response Message is send back.
6. Now exception comes and Pointer again come to ProcessingBean
7. In webservice never get response back.

P.S. If you desible Global transation in Weblogic connection Pool then everything works fine. Or If I checked enable Two-Phase commit then also everything is working fine.
 
Bartender
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
When Global Transaction is enabled and if the MDB uses CMT, then a JTA transaction is started. Resources such as datasources, JMS queue/topics etc. can participate in a JTA. But for that, the datasource has to be configured as such. DataSource should be configured as jta supported (xa) for them to participate in JTA. This is true for both JDBC or EntityManager.
You have indicated you get this exception from one of the DataSource. Which one is that? you should check the configuration of that DataSource.
 
Prashant Saraf
Ranch Hand
Posts: 57
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using oracle JDBC driver for my datasource. When I mark the Global tration as ture then I need to eable either 1-pahse commit or 2-phase commit. if I use two phase commit then application runs well but my requirement is why its not working on default setting of 1-phase commit.

I also did some stack trace and found that my OnMessage method is working as expected. when I am returning from onMessage its throwing this exception.

Thanks for your response.
Prashant
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like I pointed out earlier, if MDB is using CMT and the method has a transaction attribute which makes the container to start a transaction (which is a JTA transaction), then it is expected that all the data sources you deal with in the method have the ability to take part in a JTA transaction. Transaction commit happens at the end of the method and that is when you get this issue.
If you do not want this behaviour, then you should indicate that you want to handle the transaction yourself (BMT). This marking is done in the deployment descriptor or with annotation. When that is done, you can handle transaction in any way you want (but, remember that if you use JTA transaction programattically, then the same rules apply again).
 
Prashant Saraf
Ranch Hand
Posts: 57
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ranganathan,
Can you please provide some guideline on handling the traction on programmatic way?
Also very simple but confusing point... when I am releasing the connection why does a CMT holding it?

Thanks
Prashant Saraf
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Prashant Saraf wrote:Thanks Ranganathan,
Can you please provide some guideline on handling the traction on programmatic way?


You can read about CMT here

Prashant Saraf wrote:Also very simple but confusing point... when I am releasing the connection why does a CMT holding it?


I don't get this question. can you elaborate?
 
Prashant Saraf
Ranch Hand
Posts: 57
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ranganathan Kaliyur Mannar wrote:

Prashant Saraf wrote:Also very simple but confusing point... when I am releasing the connection why does a CMT holding it?


I don't get this question. can you elaborate?



I am getting Two-Phase commit exception for oracle connection pool and I have used Toplink as ORM. and when toplink is relasing the connection then why does my JMS saying two-phase commit on oracle connection pool.

Thanks
Prashant Saraf
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
CMT is not holding the connection. When the method ends, CMT tries to issue a commit. So, the resources should conform to that.
In your case, it means that the DataSource you configured is not a xa-datasource. TopLink is just the ORM provider - you will have to configure the datasource for TopLink to use it. It is this configuration that you should change.
reply
    Bookmark Topic Watch Topic
  • New Topic