aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Two-Phase commit Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Two-Phase commit Exception" Watch "Two-Phase commit Exception" New topic
Author

Two-Phase commit Exception

Prashant Saraf
Ranch Hand

Joined: Sep 25, 2006
Posts: 52

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.
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1096
    
  10

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.


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
Prashant Saraf
Ranch Hand

Joined: Sep 25, 2006
Posts: 52

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

Joined: Oct 16, 2003
Posts: 1096
    
  10

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

Joined: Sep 25, 2006
Posts: 52

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

Joined: Oct 16, 2003
Posts: 1096
    
  10

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

Joined: Sep 25, 2006
Posts: 52

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

Joined: Oct 16, 2003
Posts: 1096
    
  10

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Two-Phase commit Exception