title: Transaction rollbacks, but a record is inserted
body: <p>Hi all I have done an application configuration using jsf ,spring 3.0,hybernate + JPA  and atomikos for XA transcation management   and mysql is my backend,here every thing is working fine however insert operation, when exception is throwing the transcation should rollback,but it is not happening!! here is a small flow for our application 
         i am using jsfmanagedbean  to cal my servive,from my service class my transcation will start </p>
  
  <p>TextileUIBean.java<br>
           package com.textile.web;
           public class TextileUIBean extends BaseManagedBean implements Serializable,
           {
           public  insertPaymentDetails()
              {
             PaymentDetails  PaymentDetails=new PaymentDetails();
            // values are hard coded ans only two propereties  only using 
             PaymentDetails.setCustomerName("Manikandan");
             PaymentDetails.setAmount(1000);
             getTextileManager().insertPaymentDetails(PaymentDetails);
             }
                public ITextileManager getTextileManager() {
               textileManager = (ITextileManager) getBean("textileManager");
               return textileManager;
              }
             }</p>
  
  <pre><code>   service class
  
  
    package com.textile.web
         public interface ITextileManager 
         {
           public void insertPaymentDetails(PaymentDetails PaymentDetails);
         }
          package com.textile.web
          public class TextileManager implements ITextileManager 
              {
              ITextileBusiness  TextileBusiness ;
  
              public void setTextileBusiness(ITextileBusiness textileBusiness) {
             this.textileBusiness = textileBusiness;
               }
               void insertPaymentDetails(PaymentDetails PaymentDetails)
               {
                TextileBusiness.insertPaymentDetails(PaymentDetails);
  
  
               }
  
          and my business class is 
  
  
  package com.textile.web
  
               public interface ITextileBusiness
               {
                public void insertPaymentDetails(PaymentDetails PaymentDetails);
               }
  
               package com.textile.web
               public class TextileBusiness implements ITextileBusiness 
               {
               ITextileDao  textileDao;
  
              public void setTextileDao(ITextileDao textileDao) {
             this.textileDao = textileDao;
               }
               void insertPaymentDetails(PaymentDetails ormPaymentTable)
               {
  
                 OrmPaymentTable ormPaymentTable= OrmPaymentTable();
                  ormPaymentTable.setCustomerName(PaymentDetails.getCustomerName());
             ormPaymentTable.setAmount(PaymentDetails.getAmount(););
                textileDao.insertPaymentDetails(ormPaymentTable);
                                 int a=0;
                  if(a==0)
                      throw new BusinessException("Transcation Rollback");            
  
               }
               }
           and my dao class is 
  
  
   package com.textile.web
               public interface IPaymentsDao {
                public void insertPaymentDetails(OrmPaymentTable ormPaymentTable);
                }
                 package com.textile.web
                 public class PaymentsDao implements IPaymentsDao
                 {
                 void insertPaymentDetails(OrmPaymentTable ormPaymentTable)
                 {
                 this.getJpaTemplate().persist(ormPaymentTable);
                    after this line the record is insertinf into table               
                 }               
                 }
  
  
             my FacesConfig.xml is 
  
  
     &lt;application&gt;
              &lt;el-resolver&gt;org.springframework.web.jsf.el.SpringBeanFacesELResolver&lt;/el-resolver&gt;
              &lt;locale-config&gt;
              &lt;default-locale&gt;en&lt;/default-locale&gt;
              &lt;supported-locale&gt;en&lt;/supported-locale&gt;
              &lt;/locale-config&gt;
              &lt;message-bundle&gt;Messages&lt;/message-bundle&gt;
              &lt;/application&gt;
              &lt;managed-bean&gt;          &lt;managed-bean-name&gt;textileUIBean&lt;/managed-bean-name&gt;                                                    &lt;managed-bean-class&gt;com.textile.web.TextileUIBean&lt;/managed-bean-class&gt;
      &lt;managed-bean-scope&gt;view&lt;/managed-bean-scope&gt;
  &lt;/managed-bean&gt;
  </code></pre>
  
  <p>and my applicationConfig.xml file is </p>
  
  <pre><code>&lt;beans:bean id="dataSource"
          class="org.springframework.jndi.JndiObjectFactoryBean" &gt;
          &lt;beans: property name="jndiName"&gt;
              &lt;beans: value&gt;java:comp/env/jdbc/textWeb&lt;/beans:value&gt;
          &lt;/beans: property&gt; 
          &lt;beans: property name="resourceRef"&gt;
              &lt;beans:value&gt;true&lt;/beans:value&gt;
          &lt;/beans: property&gt;
       &lt;/beans: bean&gt;
          &lt;beans: bean id="jpaTemplate" class="org.springframework.orm.jpa.JpaTemplate"&gt;
          &lt;beans: property name="entityManagerFactory"&gt;
              &lt;beans: ref bean="entityManagerFactory" /&gt;
          &lt;/beans: property&gt;
      &lt;/beans: bean&gt;
      &lt;beans: bean id="entityManagerFactory"
          class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
          &lt;!-- hidden by shiju  because we need one datasource support its  in prsistence.xml !--&gt;
          &lt;beans: property name="dataSource"&gt;
              &lt;beans: ref bean="dataSource" /&gt;
          &lt;/beans: property&gt;
           &lt;beans: property name="persistenceUnitName" value="payhub" /&gt;
          &lt;beans: property name="jpaVendorAdapter"&gt;
              &lt;beans:bean
                  class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
                  &lt;beans: property name="generateDdl" value="false" /&gt;
                  &lt;beans: property name="showSql" value="true" /&gt;
                  &lt;beans: property name="databasePlatform" value="${database.target}" /&gt;
              &lt;/beans: bean&gt;
          &lt;/beans: property&gt;
          &lt;beans: property name="persistenceXmlLocation"&gt;
              &lt;beans: value&gt;classpath:META-INF/persistence.xml&lt;/beans:value&gt;
          &lt;/beans: property&gt;
      &lt;/beans: bean&gt;
  &lt;beans:bean id="textileManager"
          class=" com.textile.web.TextileManager"&gt;
          &lt;beans: property name="textileBusiness" ref="textileBusiness" /&gt;
      &lt;/beans: bean&gt;
      &lt;beans: bean id="textileBusiness" class="com.textile.web.TextileBusiness"&gt;
          &lt;beans: property name="textileDao" ref="textileDao" /&gt;       
      &lt;/beans: bean&gt;
      &lt;beans: bean id="textileDao" class="com.textile.web.textileDao"&gt;
          &lt;beans: property name="jpaTemplate"&gt;
              &lt;beans: ref bean="jpaTemplate"/&gt;
          &lt;/beans: property&gt;
      &lt;/beans: bean&gt;
  
       &lt;aop:config&gt;
              &lt;aop:pointcut id="fooServiceOperation"  expression="execution(* com.textile.web.*.*(..))"/&gt;
               &lt;aop:advisor advice-ref="txAdvice" pointcut-ref="fooServiceOperation"/&gt;
               &lt;/aop:config&gt;
      &lt;tx:advice id="txAdvice" transaction-manager="transactionManager"&gt;
       &lt;tx:attributes&gt;             
             &lt;tx:method name="*" propagation="REQUIRED"/&gt;
          &lt;/tx:attributes&gt;
      &lt;/tx:advice&gt;
  
          &lt;beans: bean id="atomikosTransactionManager"
          class="com.atomikos.icatch.jta.UserTransactionManager" init-method="init"
          destroy-method="close"&gt;
          &lt;beans: property name="forceShutdown" value="true" /&gt;
          &lt;beans: property name="startupTransactionService" value="true" /&gt;
      &lt;/beans:bean&gt;
  
      &lt;beans:bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp"&gt;
          &lt;beans: property name="transactionTimeout"&gt;
              &lt;beans: value&gt;3000&lt;/beans:value&gt;
          &lt;/beans: property&gt;
      &lt;/beans:bean&gt;
  
      &lt;beans: bean id="transactionManager"
          class="org.springframework.transaction.jta.JtaTransactionManager"&gt;
          &lt;beans: property name="transactionManager"&gt;
              &lt;beans: ref bean="atomikosTransactionManager" /&gt;
          &lt;/beans: property&gt;
          &lt;beans: property name="userTransaction"&gt;
              &lt;beans: ref bean="atomikosUserTransaction"/&gt;
          &lt;/beans: property&gt;
              &lt;beans: property name="rollbackOnCommitFailure" value="true"&gt;
              &lt;/beans: property&gt;
      &lt;/beans: bean&gt;
  
   and orm.xml file is 
  
  
  
  
  &lt;entity class="OrmPaymentTable" name="OrmPaymentTable"&gt;
  &lt;table name="ta_payment" /&gt;
  &lt;attributes&gt;
  &lt;id name="paymentId"&gt;
  &lt;column name="USER_ID" /&gt;
  &lt;generated-value strategy="AUTO" /&gt;
  &lt;/id&gt;
  &lt;basic name="customerName"&gt;
  &lt;column name="CUST_NAME" length="50" /&gt;
  &lt;/basic&gt;
  &lt;basic name="amount"&gt;
  &lt;column name="AMOUNT" length="50" /&gt;
  &lt;/basic&gt;
  &lt;/attributes&gt;
  &lt;/entity&gt; 
  
  &lt;persistence-unit name="payhub" transaction-type="JTA"&gt;
          &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt; 
          &lt;jta-data-source&gt;java:comp/env/jdbc/textWeb&lt;/jta-data-source&gt;
           &lt;mapping-file&gt;META-INF/orm.xml&lt;/mapping-file&gt;
           &lt;class&gt;com.textile.web.OrmPaymentTable&lt;/class&gt;
           &lt;properties&gt;
              &lt;property name="hibernate.transaction.manager_lookup_class"
                  value="com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup"/&gt;
  
               &lt;property name="hibernate.transaction.factory_class"
                  value="org.hibernate.transaction.JTATransactionFactory" /&gt;
   &lt;/properties&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>and i configure jndi in meta-inf/context.xml</p>
  
  <pre><code>&lt;Context&gt;
           &lt;Transaction factory="com.atomikos.icatch.jta.UserTransactionFactory"/&gt; 
           &lt;Resource name="jdbc/textWeb" auth="Container"
          driverClassName="com.mysql.jdbc.Driver" user="root" password="root"
          type="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource" factory="com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory"
          url="jdbc:mysql://localhost:3306/textWeb" explicitUrl="true"
          pinGlobalTxToPhysicalConnection="true"&gt;
      &lt;/Resource&gt; 
      &lt;/Context&gt;
  
  web.xml 
  
           &lt;resource-ref&gt;
     &lt;description&gt;PaymentsDatabase&lt;/description&gt;
     &lt;res-ref-name&gt;jdbc/textWeb&lt;/res-ref-name&gt;
     &lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt;
     &lt;res-auth&gt;Container&lt;/res-auth&gt;
     &lt;res-sharing-scope&gt;Shareable&lt;/res-sharing-scope&gt;
  &lt;/resource-ref&gt;
  </code></pre>
  
  <p>I trace the log.. see my transcation log details </p>
  
  <pre><code> 78 [main] INFO atomikos - USING core version: 3.6.4
  78 [main] INFO atomikos - USING com.atomikos.icatch.console_file_name = tm.out
  78 [main] INFO atomikos - USING com.atomikos.icatch.console_file_count = 1
  78 [main] INFO atomikos - USING com.atomikos.icatch.automatic_resource_registration = true
  78 [main] INFO atomikos - USING com.atomikos.icatch.client_demarcation = false
  78 [main] INFO atomikos - USING com.atomikos.icatch.threaded_2pc = true
  78 [main] INFO atomikos - USING com.atomikos.icatch.serial_jta_transactions = false
  78 [main] INFO atomikos - USING com.atomikos.icatch.log_base_dir = .\
  94 [main] INFO atomikos - USING com.atomikos.icatch.console_log_level = WARN
  94 [main] INFO atomikos - USING com.atomikos.icatch.max_actives = 50
  94 [main] INFO atomikos - USING com.atomikos.icatch.checkpoint_interval = 500
  94 [main] INFO atomikos - USING com.atomikos.icatch.enable_logging = false
  94 [main] INFO atomikos - USING com.atomikos.icatch.output_dir = .\
  94 [main] INFO atomikos - USING com.atomikos.icatch.log_base_name = tmlog
  94 [main] INFO atomikos - USING com.atomikos.icatch.console_file_limit = 0
  94 [main] INFO atomikos - USING com.atomikos.icatch.max_timeout = 300000
  94 [main] INFO atomikos - USING com.atomikos.icatch.tm_unique_name = PaymentsTransactions
  94 [main] INFO atomikos - USING java.naming.factory.initial = com.sun.jndi.rmi.registry.RegistryContextFactory
  94 [main] INFO atomikos - USING java.naming.provider.url = rmi://localhost:1099
  94 [main] INFO atomikos - USING com.atomikos.icatch.service = com.atomikos.icatch.standalone.UserTransactionServiceFactory
  94 [main] INFO atomikos - USING com.atomikos.icatch.force_shutdown_on_vm_exit = false
  94 [main] INFO atomikos - USING com.atomikos.icatch.default_jta_timeout = 10000
  INFO - JtaTransactionManager.checkUserTransactionAndTransactionManager(469) | Using JTA UserTransaction: com.atomikos.icatch.jta.UserTransactionImp@16a6027
  INFO - JtaTransactionManager.checkUserTransactionAndTransactionManager(480) | Using JTA TransactionManager: com.atomikos.icatch.jta.UserTransactionManager@e68513
  DEBUG - NameMatchTransactionAttributeSource.addTransactionalMethod(94) | Adding transactional method [*] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
  DEBUG - AbstractPlatformTransactionManager.getTransaction(365) | Creating new transaction with name [com.evolvus.payments.manager.IPaymentsManager.findColumnChartDisplayByGateWays]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
  40500 [http-8080-Processor24] WARN atomikos - Attempt to create a transaction with a timeout that exceeds com.atomikos.icatch.max_timeout - truncating to: 300000
  40641 [http-8080-Processor24] INFO atomikos - THREADS: using JDK thread pooling...
  40703 [http-8080-Processor24] INFO atomikos - createCompositeTransaction ( 3000000 ): created new ROOT transaction with id PaymentsTransactions0000100688
  DEBUG - AbstractPlatformTransactionManager.handleExistingTransaction(470) | Participating in existing transaction
  DEBUG - AbstractPlatformTransactionManager.handleExistingTransaction(470) | Participating in existing transaction
  DEBUG - AbstractPlatformTransactionManager.processRollback(850) | Participating transaction failed - marking existing transaction as rollback-only
  DEBUG - JtaTransactionManager.doSetRollbackOnly(1060) | Setting JTA transaction rollback-only
  49110 [http-8080-Processor24] INFO atomikos - setRollbackOnly() called for transaction PaymentsTransactions0000100688
  DEBUG - AbstractPlatformTransactionManager.processRollback(843) | Initiating transaction rollback
  49172 [http-8080-Processor24] INFO atomikos - afterCompletion ( STATUS_ROLLEDBACK ) called  on Synchronization: org.hibernate.transaction.CacheSynchronization
  49172 [http-8080-Processor24] INFO atomikos - afterCompletion ( STATUS_ROLLEDBACK ) called  on Synchronization: org.hibernate.ejb.EntityManagerImpl$1@1f6e48a
  49172 [http-8080-Processor24] INFO atomikos - rollback() done of transaction PaymentsTransactions0000100688
  </code></pre>
  
  <p>could you help me ? </p>