13 Replies Latest reply on May 8, 2014 8:00 AM by Bartosz Majsak

    Arquillian Persistence Extension Cleanup DB

    Hans-Michael Rupp Novice

      From Persistence - Arquillian - Project Documentation Editor

      "By default your database is entirely erased before each test."

       

      <?xml version="1.0" encoding="UTF-8"?>

      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

          <modelVersion>4.0.0</modelVersion>

       

          <groupId>de.rupp</groupId>

          <artifactId>jpatest</artifactId>

          <version>1.0-SNAPSHOT</version>

          <packaging>war</packaging>

          <name>Java EE 6 webapp project</name>

          <description>A starter Java EE 6 webapp project for use on JBoss AS 7.1 / EAP 6, generated from the jboss-javaee6-webapp archetype</description>

       

          <properties>

              <!-- Explicitly declaring the source encoding eliminates the following

                  message: -->

              <!-- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered

                  resources, i.e. build is platform dependent! -->

              <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

              <!-- Define the version of JBoss' Java EE 6 APIs and Tools we want

                  to import. -->

              <jboss.bom.version>1.0.0.Final</jboss.bom.version>

              <!-- Alternatively, comment out the above line, and un-comment the

                  line below to use version 1.0.0.M12-redhat-1 which is a release certified

                  to work with JBoss EAP 6. It requires you have access to the JBoss EAP 6

                  maven repository. -->

              <!-- <jboss.bom.version>1.0.0.M12-redhat-1</jboss.bom.version>> -->

          </properties>

       

       

          <dependencyManagement>

              <dependencies>

                  <!-- JBoss distributes a complete set of Java EE 6 APIs including

                      a Bill of Materials (BOM). A BOM specifies the versions of a "stack" (or

                      a collection) of artifacts. We use this here so that we always get the correct

                      versions of artifacts. Here we use the jboss-javaee-6.0-with-tools stack

                      (you can read this as the JBoss stack of the Java EE 6 APIs, with some extras

                      tools for your project, such as Arquillian for testing) and the jboss-javaee-6.0-with-hibernate

                      stack you can read this as the JBoss stack of the Java EE 6 APIs, with extras

                      from the Hibernate family of projects) -->

                  <dependency>

                      <groupId>org.jboss.bom</groupId>

                      <artifactId>jboss-javaee-6.0-with-tools</artifactId>

                      <version>${jboss.bom.version}</version>

                      <type>pom</type>

                      <scope>import</scope>

                  </dependency>

                  <dependency>

                      <groupId>org.jboss.bom</groupId>

                      <artifactId>jboss-javaee-6.0-with-hibernate</artifactId>

                      <version>${jboss.bom.version}</version>

                      <type>pom</type>

                      <scope>import</scope>

                  </dependency>

              </dependencies>

          </dependencyManagement>

         

          <dependencies>

       

              <!-- First declare the APIs we depend on and need for compilation.

                  All of them are provided by JBoss AS 7 -->

       

              <!-- Import the CDI API, we use provided scope as the API is included

                  in JBoss AS 7 -->

              <dependency>

                  <groupId>javax.enterprise</groupId>

                  <artifactId>cdi-api</artifactId>

                  <scope>provided</scope>

              </dependency>

       

              <!-- Import the Common Annotations API (JSR-250), we use provided

                  scope as the API is included in JBoss AS 7 -->

              <dependency>

                  <groupId>org.jboss.spec.javax.annotation</groupId>

                  <artifactId>jboss-annotations-api_1.1_spec</artifactId>

                  <scope>provided</scope>

              </dependency>

       

              <!-- Import the JAX-RS API, we use provided scope as the API is included

                  in JBoss AS 7 -->

              <dependency>

                  <groupId>org.jboss.spec.javax.ws.rs</groupId>

                  <artifactId>jboss-jaxrs-api_1.1_spec</artifactId>

                  <scope>provided</scope>

              </dependency>

       

              <!-- Import the JPA API, we use provided scope as the API is included

                  in JBoss AS 7 -->

              <dependency>

                  <groupId>org.hibernate.javax.persistence</groupId>

                  <artifactId>hibernate-jpa-2.0-api</artifactId>

                  <scope>provided</scope>

              </dependency>

       

              <!-- Import the EJB API, we use provided scope as the API is included

                  in JBoss AS 7 -->

              <dependency>

                  <groupId>org.jboss.spec.javax.ejb</groupId>

                  <artifactId>jboss-ejb-api_3.1_spec</artifactId>

                  <scope>provided</scope>

              </dependency>

       

              <!-- JSR-303 (Bean Validation) Implementation -->

              <!-- Provides portable constraints such as @Email -->

              <!-- Hibernate Validator is shipped in JBoss AS 7 -->

              <dependency>

                  <groupId>org.hibernate</groupId>

                  <artifactId>hibernate-validator</artifactId>

                  <scope>provided</scope>

                  <exclusions>

                      <exclusion>

                          <groupId>org.slf4j</groupId>

                          <artifactId>slf4j-api</artifactId>

                      </exclusion>

                  </exclusions>

              </dependency>

       

              <!-- Import the JSF API, we use provided scope as the API is included

                  in JBoss AS 7 -->

              <dependency>

                  <groupId>org.jboss.spec.javax.faces</groupId>

                  <artifactId>jboss-jsf-api_2.1_spec</artifactId>

                  <scope>provided</scope>

              </dependency>

       

              <!-- Now we declare any tools needed -->

       

              <!-- Annotation processor to generate the JPA 2.0 metamodel classes

                  for typesafe criteria queries -->

              <dependency>

                  <groupId>org.hibernate</groupId>

                  <artifactId>hibernate-jpamodelgen</artifactId>

                  <scope>provided</scope>

              </dependency>

       

              <!-- Annotation processor that raising compilation errors whenever

                  constraint annotations are incorrectly used. -->

              <dependency>

                  <groupId>org.hibernate</groupId>

                  <artifactId>hibernate-validator-annotation-processor</artifactId>

                  <scope>provided</scope>

              </dependency>

       

              <!-- Needed for running tests (you may also use TestNG) -->

              <dependency>

                  <groupId>junit</groupId>

                  <artifactId>junit</artifactId>

                  <scope>test</scope>

              </dependency>

       

              <!-- Optional, but highly recommended -->

              <!-- Arquillian allows you to test enterprise code such as EJBs and

                  Transactional(JTA) JPA from JUnit/TestNG -->

              <dependency>

                  <groupId>org.jboss.arquillian.junit</groupId>

                  <artifactId>arquillian-junit-container</artifactId>

                  <scope>test</scope>

              </dependency>

       

              <dependency>

                  <groupId>org.jboss.arquillian.protocol</groupId>

                  <artifactId>arquillian-protocol-servlet</artifactId>

                  <scope>test</scope>

              </dependency>

             

             

              <dependency> 

                <groupId>org.jboss.arquillian.extension</groupId> 

                <artifactId>arquillian-persistence-impl</artifactId> 

                <version>1.0.0.Alpha6</version> 

                <scope>test</scope>

              </dependency>

       

          </dependencies>

       

          <build>

              <!-- Maven will append the version to the finalName (which is the

                  name given to the generated war, and hence the context root) -->

              <finalName>${project.artifactId}</finalName>

              <plugins>

                  <!-- Compiler plugin enforces Java 1.6 compatibility and activates

                      annotation processors -->

                  <plugin>

                      <artifactId>maven-compiler-plugin</artifactId>

                      <version>2.3.1</version>

                      <configuration>

                          <source>1.6</source>

                          <target>1.6</target>

                      </configuration>

                  </plugin>

                  <plugin>

                      <artifactId>maven-war-plugin</artifactId>

                      <version>2.1.1</version>

                      <configuration>

                          <!-- Java EE 6 doesn't require web.xml, Maven needs to

                              catch up! -->

                          <failOnMissingWebXml>false</failOnMissingWebXml>

                      </configuration>

                  </plugin>

                  <!-- The JBoss AS plugin deploys your war to a local JBoss AS

                      container -->

                  <!-- To use, run: mvn package jboss-as:deploy -->

                  <plugin>

                      <groupId>org.jboss.as.plugins</groupId>

                      <artifactId>jboss-as-maven-plugin</artifactId>

                      <version>7.1.1.Final</version>

                  </plugin>

              </plugins>

          </build>

       

          <profiles>

              <profile>

                  <!-- The default profile skips all tests, though you can tune

                      it to run just unit tests based on a custom pattern -->

                  <!-- Seperate profiles are provided for running all tests, including

                      Arquillian tests that execute in the specified container -->

                  <id>default</id>

                  <activation>

                      <activeByDefault>true</activeByDefault>

                  </activation>

                  <build>

                      <plugins>

                          <plugin>

                              <artifactId>maven-surefire-plugin</artifactId>

                              <version>2.4.3</version>

                              <configuration>

                                  <skip>true</skip>

                              </configuration>

                          </plugin>

                      </plugins>

                  </build>

              </profile>

       

              <profile>

                  <!-- An optional Arquillian testing profile that executes tests

                      in your JBoss AS instance -->

                  <!-- This profile will start a new JBoss AS instance, and execute

                      the test, shutting it down when done -->

                  <!-- Run with: mvn clean test -Parq-jbossas-managed -->

                  <id>arq-jbossas-managed</id>

                  <dependencies>

                      <dependency>

                          <groupId>org.jboss.as</groupId>

                          <artifactId>jboss-as-arquillian-container-managed</artifactId>

                          <scope>test</scope>

                      </dependency>

                  </dependencies>

              </profile>

       

              <profile>

                  <!-- An optional Arquillian testing profile that executes tests

                      in a remote JBoss AS instance -->

                  <!-- Run with: mvn clean test -Parq-jbossas-remote -->

                  <id>arq-jbossas-remote</id>

                  <dependencies>

                      <dependency>

                          <groupId>org.jboss.as</groupId>

                          <artifactId>jboss-as-arquillian-container-remote</artifactId>

                          <scope>test</scope>

                      </dependency>

                  </dependencies>

              </profile>

       

              <profile>

                  <!-- When built in OpenShift the 'openshift' profile will be

                      used when invoking mvn. -->

                  <!-- Use this profile for any OpenShift specific customization

                      your app will need. -->

                  <!-- By default that is to put the resulting archive into the

                      'deployments' folder. -->

                  <!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->

                  <id>openshift</id>

                  <build>

                      <plugins>

                          <plugin>

                              <artifactId>maven-war-plugin</artifactId>

                              <version>2.1.1</version>

                              <configuration>

                                  <outputDirectory>deployments</outputDirectory>

                                  <warName>ROOT</warName>

                              </configuration>

                          </plugin>

                      </plugins>

                  </build>

              </profile>

       

          </profiles>

      </project>

       

      package jpatest.control.test;

       

      import static org.junit.Assert.assertEquals;

      import static org.junit.Assert.assertNotNull;

       

      import java.util.List;

       

      import javax.ejb.EJB;

       

      import jpatest.control.AktionDAO;

      import jpatest.control.AktionDAOBean;

      import jpatest.entity.Aktion;

      import jpatest.entity.Spende;

       

      import org.jboss.arquillian.container.test.api.Deployment;

      import org.jboss.arquillian.junit.Arquillian;

      import org.jboss.shrinkwrap.api.Archive;

      import org.jboss.shrinkwrap.api.ShrinkWrap;

      import org.jboss.shrinkwrap.api.spec.WebArchive;

      import org.junit.Test;

      import org.junit.runner.RunWith;

       

      @RunWith(Arquillian.class)

      public class AktionDAOTest {

         

          @EJB

          AktionDAO aktionDAO;

         

          @Deployment

          public static Archive<?> createTestArchive() {

              return ShrinkWrap.create(WebArchive.class, "test.war")

                      .addClasses(Aktion.class, Spende.class, AktionDAO.class, AktionDAOBean.class)

                      .addAsResource("META-INF/persistence.xml");

          }

         

          @Test

          public void addAktion() {

              Aktion aktion = new Aktion();

              aktion.setName("Bla");

              Spende spende = new Spende();

              spende.setName("Hans");

              spende.setAmount(1000.0);

              aktion.addSpende(spende);

              spende.setAktion(aktion);

              aktionDAO.save(aktion);

              List<Aktion> aktionen = aktionDAO.getAll();

              assertNotNull(aktionen);

              assertEquals(1, aktionen.size());

          }

       

      }

       

      The test fails because an entity is added to the database in each test and the database is not clean after each test.

      What is the easiest way (apart from using ROLLBACK) to the clean the db after each test with Arquillian Persistence?

       

      Another problem: I often get "Unrooted Tests" from JBoss Developer Studio.

      Active Maven profile: arq-jbossas-remote

       

      Thanks,

       

      Hans

        • 1. Re: Arquillian Persistence Extension Cleanup DB
          Bartosz Majsak Master

          Hi Hans,

           

          this test is not using Persistence Extension, therefore it won't be enabled - that's why there is no cleanup. You either mark test class @PersistenceTest or use @Cleanup annotation which actually let you define when it should occur.

           

          HTH

          • 2. Re: Arquillian Persistence Extension Cleanup DB
            Hans-Michael Rupp Novice

            Thanks for your answer,

             

            after marking the class with @PersistenceTest

            I get a

            javax.ejb.EJBTransactionRolledbackException: org.hibernate.HibernateException: Could not apply work

                at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:138)

                at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:228)

                at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:317)

                at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:214)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

               ...

            Exception

            • 3. Re: Re: Arquillian Persistence Extension Cleanup DB
              Bartosz Majsak Master

              Persistence Extension uses Transactions for the tests, probably you will need to add following to your arquillian.xml:

               

              <extension qualifier="transaction">
                  <property name="manager">java:jboss/UserTransaction</property>
              </extension>
              

               

              Let me know if that helps.

              • 4. Re: Re: Arquillian Persistence Extension Cleanup DB
                Hans-Michael Rupp Novice

                src/test/resources/arquillian.xml:

                 

                <?xml version="1.0" encoding="UTF-8"?>

                <arquillian xmlns="http://jboss.org/schema/arquillian"

                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                   xsi:schemaLocation="http://jboss.org/schema/arquillian

                        http://jboss.org/schema/arquillian/arquillian_1_0.xsd">

                 

                   <!-- Uncomment to have test archives exported to the file system for inspection -->

                <!--    <engine>  -->

                <!--       <property name="deploymentExportPath">target/</property>  -->

                <!--    </engine> -->

                 

                   <!-- Force the use of the Servlet 3.0 protocol with all containers, as it is the most mature -->

                   <defaultProtocol type="Servlet 3.0" />

                 

                   <!-- Example configuration for a remote JBoss AS 7 instance -->

                   <container qualifier="jboss" default="true">

                      <!-- If you want to use the JBOSS_HOME environment variable, just delete the jbossHome property -->

                      <configuration>

                         <property name="jbossHome">D:\Programmierung\JEE6\jboss-eap-6.1</property>

                      </configuration>

                   </container>

                   

                    <extension qualifier="transaction">

                        <property name="manager">java:jboss/UserTransaction</property>

                    </extension>

                </arquillian>

                 

                With that I get

                -------------------------------------------------------------------------------

                Test set: jpatest.control.test.AktionDAOTest

                -------------------------------------------------------------------------------

                Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 6.244 sec <<< FAILURE!

                addAktion(jpatest.control.test.AktionDAOTest)  Time elapsed: 0.556 sec  <<< ERROR!

                javax.ejb.EJBTransactionRolledbackException: org.hibernate.HibernateException: Could not apply work

                    at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:138)

                    at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:228)

                    at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:317)

                    at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:214)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:55)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

                    at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)

                    at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:182)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

                    at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72)

                    at jpatest.control.AktionDAO$$$view4.save(Unknown Source)

                    at jpatest.control.test.AktionDAOTest.addAktion(AktionDAOTest.java:50)

                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                    at java.lang.reflect.Method.invoke(Method.java:601)

                    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)

                    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

                    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)

                    at org.jboss.arquillian.junit.Arquillian$6$1.invoke(Arquillian.java:270)

                    at org.jboss.arquillian.container.test.impl.execution.LocalTestExecuter.execute(LocalTestExecuter.java:60)

                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                    at java.lang.reflect.Method.invoke(Method.java:601)

                    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

                    at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

                    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

                    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)

                    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)

                    at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)

                    at org.jboss.arquillian.container.test.impl.execution.ContainerTestExecuter.execute(ContainerTestExecuter.java:38)

                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                    at java.lang.reflect.Method.invoke(Method.java:601)

                    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

                    at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

                    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

                    at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:89)

                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                    at java.lang.reflect.Method.invoke(Method.java:601)

                    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

                    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                    at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)

                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                    at java.lang.reflect.Method.invoke(Method.java:601)

                    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

                    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                    at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)

                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                    at java.lang.reflect.Method.invoke(Method.java:601)

                    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

                    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)

                    at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:111)

                    at org.jboss.arquillian.junit.Arquillian$6.evaluate(Arquillian.java:263)

                    at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:226)

                    at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)

                    at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)

                    at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:240)

                    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

                    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

                    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

                    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

                    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

                    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

                    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

                    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

                    at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:185)

                    at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)

                    at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)

                    at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:199)

                    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

                    at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)

                    at org.junit.runner.JUnitCore.run(JUnitCore.java:157)

                    at org.junit.runner.JUnitCore.run(JUnitCore.java:136)

                    at org.jboss.arquillian.junit.container.JUnitTestRunner.execute(JUnitTestRunner.java:65)

                    at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.executeTest(ServletTestRunner.java:160)

                    at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.execute(ServletTestRunner.java:126)

                    at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.doGet(ServletTestRunner.java:90)

                    at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)

                    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)

                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)

                    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)

                    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)

                    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)

                    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)

                    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)

                    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145)

                    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)

                    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)

                    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336)

                    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)

                    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)

                    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920)

                    at java.lang.Thread.run(Thread.java:722)

                Caused by: javax.persistence.PersistenceException: org.hibernate.HibernateException: Could not apply work

                    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387)

                    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1310)

                    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1316)

                    at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:881)

                    at org.jboss.as.jpa.container.AbstractEntityManager.persist(AbstractEntityManager.java:563)

                    at jpatest.control.AktionDAOBean.save(AktionDAOBean.java:20)

                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                    at java.lang.reflect.Method.invoke(Method.java:601)

                    at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

                    at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:58)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

                    at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:58)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

                    at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:226)

                    ... 115 more

                Caused by: org.jboss.arquillian.test.spi.ArquillianProxyException: org.hibernate.HibernateException : Could not apply work [Proxied because : Original exception not deserilizable, ClassNotFoundException]

                    at org.hibernate.engine.transaction.internal.jta.JtaIsolationDelegate.doTheWorkInNewTransaction(JtaIsolationDelegate.java:137)

                    at org.hibernate.engine.transaction.internal.jta.JtaIsolationDelegate.delegateWork(JtaIsolationDelegate.java:90)

                    at org.hibernate.id.enhanced.TableStructure$1.getNextValue(TableStructure.java:119)

                    at org.hibernate.id.enhanced.OptimizerFactory$NoopOptimizer.generate(OptimizerFactory.java:252)

                    at org.hibernate.id.enhanced.SequenceStyleGenerator.generate(SequenceStyleGenerator.java:369)

                    at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:117)

                    at org.hibernate.ejb.event.EJB3PersistEventListener.saveWithGeneratedId(EJB3PersistEventListener.java:78)

                    at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:208)

                    at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:151)

                    at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:78)

                    at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:852)

                    at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:826)

                    at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:830)

                    at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:875)

                    ... 141 more

                Caused by: org.jboss.arquillian.test.spi.ArquillianProxyException: org.hibernate.id.IdentifierGenerationException : could not read a hi value - you need to populate the table: hibernate_sequence [Proxied because : Original exception not deserilizable, ClassNotFoundException]

                    at org.hibernate.id.enhanced.TableStructure$1$1.execute(TableStructure.java:138)

                    at org.hibernate.id.enhanced.TableStructure$1$1.execute(TableStructure.java:120)

                    at org.hibernate.jdbc.WorkExecutor.executeReturningWork(WorkExecutor.java:72)

                    at org.hibernate.jdbc.AbstractReturningWork.accept(AbstractReturningWork.java:51)

                    at org.hibernate.engine.transaction.internal.jta.JtaIsolationDelegate.doTheWork(JtaIsolationDelegate.java:158)

                    at org.hibernate.engine.transaction.internal.jta.JtaIsolationDelegate.doTheWorkInNewTransaction(JtaIsolationDelegate.java:125)

                    ... 154 more

                 

                Many thanks for your input.

                 

                Hans

                • 5. Re: Re: Arquillian Persistence Extension Cleanup DB
                  Hans-Michael Rupp Novice

                  Update:

                  The cleaning up aspect has worked. The database tables are empy.

                  After removing the Arquillian persistence Annotations from the test and even the maven dependency, I still cannot insert an entity into the database (which has worked before trying to configure Arquillian Persistence Extension (see my first post).

                  I still get org.hibernate.id.IdentifierGenerationException : could not read a hi value - you need to populate the table: hibernate_sequence

                  I use a MySQL database (5.0.18). I have played around somewhat with JPA with this DBA and cannot remember to have seen this error before.

                  • 6. Re: Re: Arquillian Persistence Extension Cleanup DB
                    Bartosz Majsak Master

                    As you are relying on hibernate_sequence table you obviously cannot delete all the tables (nor their content). This is visible in the full stack trace from your example.

                    org.hibernate.id.IdentifierGenerationException : could not read a hi value - you need to populate the table: hibernate_sequence

                    In order to make it all working nicely you only need to tell persitence extenstion that hibernate_sequence table should not be cleaned up

                    arquillian-extension-persistence/int-tests/src/test/resources-jboss-7.0.2-mysql/arquillian.xml at master · arquillian/ar…

                    • 7. Re: Re: Arquillian Persistence Extension Cleanup DB
                      Bartosz Majsak Master

                      Can you share your persistence.xml which you are using for tests?

                      • 8. Re: Re: Arquillian Persistence Extension Cleanup DB
                        Hans-Michael Rupp Novice

                        <?xml version="1.0" encoding="UTF-8"?>

                        <persistence version="2.0"

                           xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                           xsi:schemaLocation="

                                http://java.sun.com/xml/ns/persistence

                                http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">

                           <persistence-unit name="JPATest">

                              <!-- If you are running in a production environment, add a managed

                                 data source, the example data source is just for development and testing! -->

                              <jta-data-source>java:jboss/JPATest</jta-data-source>

                              <properties>

                                 <!-- Properties for Hibernate -->

                                 <property name="hibernate.hbm2ddl.auto" value="update" />

                                 <property name="hibernate.show_sql" value="false" />

                              </properties>

                           </persistence-unit>

                        </persistence>

                         

                        arquillian.xml:

                        <?xml version="1.0" encoding="UTF-8"?>

                        <arquillian xmlns="http://jboss.org/schema/arquillian"

                           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                           xsi:schemaLocation="http://jboss.org/schema/arquillian

                                http://jboss.org/schema/arquillian/arquillian_1_0.xsd">

                               

                           <!-- Force the use of the Servlet 3.0 protocol with all containers, as it is the most mature -->

                           <defaultProtocol type="Servlet 3.0" />

                         

                           <!-- Uncomment to have test archives exported to the file system for inspection -->

                           <engine>

                               <property name="deploymentExportPath">target/testarchives</property> 

                           </engine>

                         

                          

                         

                           <!-- Example configuration for a remote JBoss AS 7 instance -->

                           <container qualifier="jboss" default="true">

                              <!-- If you want to use the JBOSS_HOME environment variable, just delete the jbossHome property -->

                              <configuration>

                                 <property name="jbossHome">D:\Programmierung\JEE6\jboss-eap-6.1</property>

                              </configuration>

                           </container>

                           

                            

                            <extension qualifier="transaction">

                                <property name="manager">java:jboss/UserTransaction</property>

                            </extension>

                           

                            <extension qualifier="persistence-dbunit">

                            <property name="schema">JPATest</property>

                            <property name="datatypeFactory">org.dbunit.ext.mysql.MySqlDataTypeFactory</property>

                            <property name="metadataHandler">org.dbunit.ext.mysql.MySqlMetadataHandler</property>

                            <property name="caseSensitiveTableNames">true</property>

                            <property name="excludeTablesFromComparisonWhenEmptyExpected">hibernate_sequence</property>

                            <property name="excludeTablesFromCleanup">hibernate_sequence</property>

                            <!--  <property name="filterTables">true</property> -->

                          </extension>

                           

                        </arquillian>

                         

                        package jpatest.control.test;

                         

                        import static org.junit.Assert.assertEquals;

                        import static org.junit.Assert.assertNotNull;

                         

                        import java.util.List;

                         

                        import javax.ejb.EJB;

                         

                        import jpatest.control.AktionDAO;

                        import jpatest.control.AktionDAOBean;

                        import jpatest.entity.Aktion;

                        import jpatest.entity.Spende;

                         

                        import org.jboss.arquillian.container.test.api.Deployment;

                        import org.jboss.arquillian.junit.Arquillian;

                        import org.jboss.arquillian.persistence.PersistenceTest;

                        import org.jboss.shrinkwrap.api.Archive;

                        import org.jboss.shrinkwrap.api.ShrinkWrap;

                        import org.jboss.shrinkwrap.api.spec.WebArchive;

                        import org.junit.Test;

                        import org.junit.runner.RunWith;

                         

                        @RunWith(Arquillian.class)

                        @PersistenceTest

                        public class AktionDAOTest {

                           

                            @EJB

                            AktionDAO aktionDAO;

                           

                            @Deployment

                            public static Archive<?> createTestArchive() {

                                return ShrinkWrap.create(WebArchive.class, "test.war")

                                        .addClasses(Aktion.class, Spende.class, AktionDAO.class, AktionDAOBean.class)

                                        .addAsResource("META-INF/persistence.xml");

                            }

                           

                            @Test

                        //    @Cleanup

                            public void addAktion() {

                                Aktion aktion = new Aktion();

                                aktion.setName("Bla");

                                Spende spende = new Spende();

                                spende.setName("Hans");

                                spende.setAmount(1000.0);

                                aktion.addSpende(spende);

                                spende.setAktion(aktion);

                                aktionDAO.save(aktion);

                                List<Aktion> aktionen = aktionDAO.getAll();

                                assertNotNull(aktionen);

                                assertEquals(1, aktionen.size());

                            }

                         

                        }

                         

                        With that I get

                        -------------------------------------------------------------------------------

                        Test set: jpatest.control.test.AktionDAOTest

                        -------------------------------------------------------------------------------

                        Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 8.082 sec <<< FAILURE!

                        addAktion(jpatest.control.test.AktionDAOTest)  Time elapsed: 0.287 sec  <<< ERROR!

                        java.lang.RuntimeException: Unable to commit the transaction.

                            at org.jboss.arquillian.transaction.jta.provider.JtaTransactionProvider.commitTransaction(JtaTransactionProvider.java:79)

                            at org.jboss.arquillian.transaction.impl.lifecycle.TransactionHandler.endTransactionAfterTest(TransactionHandler.java:111)

                            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                            at java.lang.reflect.Method.invoke(Method.java:601)

                            at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

                            at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

                            at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

                            at org.jboss.arquillian.testenricher.cdi.CreationalContextDestroyer.destory(CreationalContextDestroyer.java:44)

                            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                            at java.lang.reflect.Method.invoke(Method.java:601)

                            at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

                            at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                            at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:89)

                            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                            at java.lang.reflect.Method.invoke(Method.java:601)

                            at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

                            at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                            at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)

                            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                            at java.lang.reflect.Method.invoke(Method.java:601)

                            at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

                            at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                            at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)

                            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                            at java.lang.reflect.Method.invoke(Method.java:601)

                            at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

                            at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                            at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)

                            at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)

                            at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.after(EventTestRunnerAdaptor.java:103)

                            at org.jboss.arquillian.junit.Arquillian$5$1.evaluate(Arquillian.java:245)

                            at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)

                            at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)

                            at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:240)

                            at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

                            at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

                            at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

                            at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

                            at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

                            at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

                            at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

                            at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

                            at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:185)

                            at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)

                            at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)

                            at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:199)

                            at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

                            at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)

                            at org.junit.runner.JUnitCore.run(JUnitCore.java:157)

                            at org.junit.runner.JUnitCore.run(JUnitCore.java:136)

                            at org.jboss.arquillian.junit.container.JUnitTestRunner.execute(JUnitTestRunner.java:65)

                            at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.executeTest(ServletTestRunner.java:160)

                            at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.execute(ServletTestRunner.java:126)

                            at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.doGet(ServletTestRunner.java:90)

                            at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)

                            at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

                            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)

                            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)

                            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)

                            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)

                            at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)

                            at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)

                            at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)

                            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145)

                            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)

                            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)

                            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336)

                            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)

                            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)

                            at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920)

                            at java.lang.Thread.run(Thread.java:722)

                        Caused by: java.lang.NullPointerException

                            at org.jboss.arquillian.transaction.jta.provider.JtaTransactionProvider.isTransactionMarkedToRollback(JtaTransactionProvider.java:137)

                            at org.jboss.arquillian.transaction.jta.provider.JtaTransactionProvider.commitTransaction(JtaTransactionProvider.java:73)

                            ... 80 more

                         

                        Curiosly running the test the second time (from IDE) I get an assertion failure:

                        java.lang.AssertionError: expected:<1> but was:<2>

                        • 9. Re: Re: Arquillian Persistence Extension Cleanup DB
                          Hans-Michael Rupp Novice

                          I think

                          @RunWith(Arquillian.class)

                          @PersistenceTest

                          public class AktionDAOTest

                           

                          alone does not cause a cleanup now. I get AssertionErrors.

                          When I add

                          @Cleanup(phase=TestExecutionPhase.BEFORE)

                          to the test Method, I get the NullPointer in Transaction like above.

                          • 10. Re: Re: Arquillian Persistence Extension Cleanup DB
                            Bartosz Majsak Master

                            That's interesting. I will try to reproduce this problem. Maybe updating tx-extension to the latest 1.0.1.Final will help.

                            • 11. Re: Re: Arquillian Persistence Extension Cleanup DB
                              Hans-Michael Rupp Novice

                              I have added

                              <dependency>

                                  <groupId>org.jboss.arquillian.extension</groupId>

                                  <artifactId>arquillian-transaction-api</artifactId>

                                  <version>1.0.1.Final</version>

                              </dependency>

                              but that does not improve anything

                              • 12. Re: Re: Arquillian Persistence Extension Cleanup DB
                                Bartosz Majsak Master

                                You not only need api, as it contains only annotations, not the implementation which is used, you should include -jta and this will include following:

                                org.jboss.arquillian.extension:arquillian-transaction-jta:jar:1.0.1.Final:test

                                   (transitive)   org.jboss.arquillian.extension:arquillian-transaction-api:jar:1.0.1.Final:test

                                   (transitive)   org.jboss.arquillian.extension:arquillian-transaction-spi:jar:1.0.1.Final:test

                                   (transitive)   org.jboss.arquillian.extension:arquillian-transaction-impl-base:jar:1.0.1.Final:test

                                 

                                You will also need to exclude the one which is transitive dependency of persistence extension.

                                • 13. Re: Arquillian Persistence Extension Cleanup DB
                                  Bartosz Majsak Master

                                  Any update on this one? If you are still having problems you can share it through Github and can fix it for you.

                                   

                                  Cheers,

                                  Bartosz