Results 1 to 6 of 6

Thread: java.sql.SQLException: Cannot call Connection.commit in distributed transaction

  1. #1
    Join Date
    Mar 2006
    Posts
    20

    Default java.sql.SQLException: Cannot call Connection.commit in distributed transaction

    Hi,

    I am using Hibernate to do the data base operations. its running on the weblogic server. I am getting the following error while trying to update a data to the DB
    Please do let me know how do i solve this problem
    java.sql.SQLException: Cannot call Connection.commit in distributed transaction. Transaction Manager will commit the resource manager when the distributed transaction is committed.
    at weblogic.jdbc.wrapper.JTSConnection.commit(JTSConn ection.java:628)
    at org.hibernate.transaction.JDBCTransaction.commitAn dResetAutoCommit(JDBCTransaction.java:119)
    at org.hibernate.transaction.JDBCTransaction.commit(J DBCTransaction.java:95)

  2. #2
    Join Date
    Jun 2006
    Posts
    2

    Default

    I got the exact same problem. Did you solve the problem? Any experts can give us some advice?

  3. #3
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    What's your configuration? Seems like you are using a mixed strategy of Local and JTA transactions. please post your relevant application context.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  4. #4
    Join Date
    Jun 2006
    Posts
    2

    Default

    Hi Costin, thanks for your response.

    I have two databases(configDB and statsDB in MySQL) and a servicesEJB ear deployed in application server(weblogic8.1.x), configEJB access configDB and statsEJB access statsDB. Only when servicesEJB deployed in a clustering enviornment, I got connection.commit() error. I was using Hibernate Transaction - SessionFactoryUtils.getSession(this.getSessionFact ory(), false).beginTransaction() .

    I started to try JTA yesterday,
    InitialContext ctx = new InitialContext();
    tx = (UserTransaction)ctx.lookup("java:comp/UserTransaction");
    tx.begin();
    ....
    but this time I got another error "Another transaction is associated with this thread. Existing transaction Name=statsEJB...". statsEJB calls statsDAO. when tx.begin called in statsDAO, I got this exception.

    Here is the configuraiton:

    <!--############## Configuration Transaction Manager and Interceptor ###############-->
    <bean id="configTransactionManager" class="org.springframework.orm.hibernate3.Hibernat eTransactionManager">
    <property name="sessionFactory"><ref bean="configSessionFactory"/></property>
    </bean>

    <bean id="configHibernateInterceptor" class="org.springframework.orm.hibernate3.Hibernat eInterceptor">
    <property name="sessionFactory"><ref bean="configSessionFactory"/></property>
    </bean>

    <!--############## Stats Transaction Manager and Interceptor ###############-->
    <bean id="statsTransactionManager" class="org.springframework.orm.hibernate3.Hibernat eTransactionManager">
    <property name="sessionFactory"><ref bean="statsSessionFactory"/></property>
    </bean>

    <bean id="statsHibernateInterceptor" class="org.springframework.orm.hibernate3.Hibernat eInterceptor">
    <property name="sessionFactory"><ref bean="statsSessionFactory"/></property>
    </bean>

  5. #5
    Join Date
    Feb 2007
    Posts
    1

    Default

    Hi,

    I am facing the same problem as FWU ... can somebody please help me out with the solution ASAP ? I am a newbie to J2EE development and all the database related configurations were done by earlier development members. One of my modules needs to manually commit/Rollback transactions. But, I am not able to do it & I am getting exaclty same Exceptions as ones mentioned by fwu ... so it will be great help if some expert can provide help to solve the problem

    Thanks in advance.

  6. #6
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    You should not normally use local transactions (HibernateTransactionManager or API calls on Hibernate Session) in an application server environment such as WebLogic. Use WebLogicJtaTransactionManagement.

    It's better to let Spring manage transactions for you than to use APIs such as JTA or Hibernate or JDBC directly to do tx mgt. If you do the latter, you restrict the environments in which your code can run.

    HTH,
    Rod
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •