2 Replies Latest reply on Mar 18, 2013 6:21 PM by Dmitriy Yermolovich

    Strange behaviour of transaction when using Arquillian's Persistence Extension

    Dmitriy Yermolovich Newbie

      Hello All,


      I wrote a little test project to learn Arquillian and its facilities. Now I am trying to understand how Arquillian's Persistence Extension is working and I faced with some strange behaviour. At least it seems to me so). Here is details:


      I have simple test method:



      @Cleanup(phase = TestExecutionPhase.NONE)
      public class ItemFacadeTest {
           private ItemFacadeLocal facade;
           public void testAutomaticTransactionRollbackAfterException() {
                Item item = new Item();
                throw new RuntimeException();


      As you can see test method is wrapped with transaction. TransactionMode is COMMIT by default. In this method I explicitly throw an exception and I expect that transaction will be rolled back after exception. But changes still in the DB after exception have been thrown. If I set TransactionMode=ROLLBACK then all is rolled back as it should be.


      Is this correct behavior? Because I think that transaction should roll back after exception have been thrown.


      By the way, I also tested Arquillian's Transaction Extension and there transaction is rolling back after exception have occured. But I faced another issue with Transaction Extension wich I will describe in another question.


      My arquillian.xml file is:



      <arquillian xmlns="http://jboss.org/schema/arquillian"
          <container qualifier="jbossas-7-managed" default="true">
                  <property name="jbossHome">D:\Programs\jboss-as-7.1.1.Final</property>
                  <property name="serverConfig">standalone-full.xml</property>
                  <property name="allowConnectingToRunningServer">true</property> 
             <protocol type="Servlet 3.0"/>
               <extension qualifier="persistence">
                    <property name="defaultDataSource">java:/mydb</property>
                    <property name="userTransactionJndi">java:jboss/UserTransaction</property>
                <extension qualifier="persistence-dbunit">
                    <property name="datatypeFactory">org.dbunit.ext.mssql.MsSqlDataTypeFactory</property>
                    <property name="useIdentityInsert">true</property>
                    <property name="excludePoi">true</property>
                    <property name="dataSeedStrategy">REFRESH</property>
                 <extension qualifier="transaction">
                    <property name="manager">java:jboss/UserTransaction</property>