This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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.
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.
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.
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).
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?
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.
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.