2 Replies Latest reply on Aug 4, 2009 12:29 AM by Rajika Kumarasiri

    You cannot commit during a managed transaction!, while using

    Rajika Kumarasiri Newbie

      hello everybody,
      I an application deployed in JBOSS5.0.0GA. And I am on linux platform. Within my application I have used the following codes. So my JTA provider will be JBOss JTA.

      
      TransactionManager transactionManager;
      transactionManager = getTransactionManager(); //get the tx manager.
      
      if(action.equal("commit")){
       transactionManager.commit();
      } else if(action.equal("rollback")){
       transactionManager.rollback();
      } else if(action.equal("new")){
       transactionManager.begin();
      }
      


      based on the action my app will start, commit, rollback a tx. I deployed my app with a datasource (for derby) and when using it I am getting the following exception.

      15:07:32,465 INFO [STDOUT] 15:07:32,465 WARN [FaultHandler] ERROR_DETAIL : org.apache.synapse.SynapseException: Error execuring insert statement : update company set price=? where name =? against DataSource : localhost:1099
       at org.apache.synapse.mediators.AbstractMediator.handleException(AbstractMediator.java:275)
       at org.apache.synapse.mediators.db.DBReportMediator.processStatement(DBReportMediator.java:61)
       at org.apache.synapse.mediators.db.AbstractDBMediator.mediate(AbstractDBMediator.java:102)
       at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:60)
       at org.apache.synapse.mediators.filters.OutMediator.mediate(OutMediator.java:55)
       at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:60)
       at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:115)
       at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:131)
       at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:339)
       at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:135)
       at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:178)
       at org.apache.synapse.transport.nhttp.ClientWorker.run(ClientWorker.java:230)
       at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:58)
       at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: java.sql.SQLException: You cannot commit during a managed transaction!
       at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.jdbcCommit(BaseWrapperManagedConnection.java:659)
       at org.jboss.resource.adapter.jdbc.WrappedConnection.commit(WrappedConnection.java:486)
       at org.apache.synapse.mediators.db.DBReportMediator.processStatement(DBReportMediator.java:57)
       ... 14 more
      
      

      When I don't use datasource this works fine. It only occurs when I use datasource.
      Any help to fix the problem is greatly appreciated. Thanks in advance.