Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Distributed Transactions Exception in J2EE

Posted on 2004-10-29
Medium Priority
Last Modified: 2013-11-24
Hi all,
I'm facing a problem while developing some code in J2EE. I have a class which has two methods. One to insert a record in table ABC and another to update a record in table DEF. The transaction should be such that if there is an exception in either of the operations, the whole transaction should be rolled back. I'm calling the second method from the first one. While the first one is called from a session bean. When I use conn.commit() or conn.rollback(), it throws an exception saying commit or rollback cannot be called in distributed transactions.
also the whole transaction does not rollback. How can I properly handle such exceptions, and ensure that either both or none of the transactions occur?
Is it a problem of the driver used. I'm using Oracle as database, and Weblogic 8 as the app server.

can anybody help me out?
thanks in advance
Question by:kirtan_a
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 13

Accepted Solution

petmagdy earned 400 total points
ID: 12450851

never use commit() or rollback() in EJB container, to do ur transaction:

1- make sure that u r getting ur DB  connections from Datasource
2- Use Declarative Transaction mangment, in ur ejb-jar.xml declare ur Session API as Transaction Type Required like this:


            <method-intf>Remote or Local</method-intf>



by this way the Container will manage ur transaction and automatically if insertion into last table failed will roll back the transaction


Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question