8 Replies Latest reply on Sep 26, 2012 12:56 PM by Bartosz Majsak

    Why does Persistence Extension require data source configuration?

    Aliaksei Lahachou Newbie

      Hello World!

       

      I have some persistence tests where use @Before and @After to begin and end transactions:

       

      @PersistenceContext(unitName = "InteropsMSSQLPU")
      private EntityManager em;
      
      @Inject
      private UserTransaction tx;
      
      @Before
      public void beginTransaction() throws Exception
      {
          tx.begin();
          em.joinTransaction();
      }
      
      @After
      public void commitTransaction() throws Exception
      {
          tx.commit();
      }
      

       

      I wanted to replace them with @Transactional annotation from Arquillian Persistence Extension, and I needed nothing else. However, if I add @Transactional, it throws me an exception:

       

      org.jboss.arquillian.persistence.exception.DataSourceNotDefinedException: DataSource not defined! Please declare in arquillian.xml or by using @DataSource annotation.
      

       

      I don't understand why it requires me to specify data source at all. I work with several data sources in my tests and I'm not very happy to have to specify data sources on classes/methods.

       

      For testing purposes I added a @DataSource annotation on the test class, but I got the following exception:

       

      org.jboss.arquillian.persistence.data.dbunit.exception.DBUnitDataSetHandlingException: Unable to clean database.
          at org.jboss.arquillian.persistence.data.dbunit.cleanup.StrictCleanupStrategyExecutor.cleanupDatabase(StrictCleanupStrategyExecutor.java:46)
          at org.jboss.arquillian.persistence.data.dbunit.DBUnitDataHandler.cleanDatabase(DBUnitDataHandler.java:190)
          at org.jboss.arquillian.persistence.data.dbunit.DBUnitDataHandler.cleanup(DBUnitDataHandler.java:122)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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.persistence.data.dbunit.DBUnitDataStateLogger.aroundCleanup(DBUnitDataStateLogger.java:108)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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.core.impl.EventImpl.fire(EventImpl.java:67)
          at org.jboss.arquillian.persistence.lifecycle.DataCleanupHandler.prepareDatabase(DataCleanupHandler.java:60)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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.persistence.data.dbunit.DBUnitPersistenceTestLifecycleHandler.createDatabaseConnection(DBUnitPersistenceTestLifecycleHandler.java:80)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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.persistence.lifecycle.ErrorCollectorHandler.createErrorCollector(ErrorCollectorHandler.java:38)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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.core.impl.EventImpl.fire(EventImpl.java:67)
          at org.jboss.arquillian.persistence.lifecycle.PersistenceTestTrigger.beforeTest(PersistenceTestTrigger.java:91)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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.before(EventTestRunnerAdaptor.java:95)
          at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:222)
          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.jmx.JMXTestRunner.runTestMethodInternal(JMXTestRunner.java:128)
          at org.jboss.arquillian.protocol.jmx.JMXTestRunner.runTestMethod(JMXTestRunner.java:107)
          at org.jboss.as.arquillian.service.ArquillianService$ExtendedJMXTestRunner.runTestMethod(ArquillianService.java:226)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:93)
          at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:27)
          at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:208)
          at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:120)
          at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:262)
          at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
          at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
          at org.jboss.as.jmx.PluggableMBeanServerImpl$TcclMBeanServer.invoke(PluggableMBeanServerImpl.java:498)
          at org.jboss.as.jmx.PluggableMBeanServerImpl.invoke(PluggableMBeanServerImpl.java:246)
          at org.jboss.remotingjmx.protocol.v1.ServerProxy$InvokeHandler.handle(ServerProxy.java:1034)
          at org.jboss.remotingjmx.protocol.v1.ServerProxy$MessageReciever$1.run(ServerProxy.java:215)
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
          at java.lang.Thread.run(Thread.java:662)
      Caused by: java.sql.SQLException: Invalid object name 'trace_xe_event_map'.
          at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368)
          at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820)
          at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2258)
          at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:632)
          at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:584)
          at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:546)
          at net.sourceforge.jtds.jdbc.JtdsStatement.executeImpl(JtdsStatement.java:723)
          at net.sourceforge.jtds.jdbc.JtdsStatement.execute(JtdsStatement.java:1160)
          at org.jboss.jca.adapters.jdbc.WrappedStatement.execute(WrappedStatement.java:153)
          at org.dbunit.database.statement.SimpleStatement.executeBatch(SimpleStatement.java:69)
          at org.dbunit.operation.DeleteAllOperation.execute(DeleteAllOperation.java:126)
          at org.dbunit.operation.TransactionOperation.execute(TransactionOperation.java:78)
          at org.jboss.arquillian.persistence.data.dbunit.cleanup.StrictCleanupStrategyExecutor.cleanupDatabase(StrictCleanupStrategyExecutor.java:42)
          ... 160 more
      

       

      I think it dropped some internal table of jTDS, so I tried to disable cleanup completely, but there are only STRICT, USED_ROWS_ONLY, and USED_TABLES_ONLY cleanup strategies, there is no disable. USED_ROWS_ONLY and USED_TABLES_ONLY give me

       

      org.jboss.arquillian.persistence.data.dbunit.exception.DBUnitDataSetHandlingException: Unable to clean database.
          at org.jboss.arquillian.persistence.data.dbunit.cleanup.SeededDataOnlyCleanupStrategyExecutor.cleanupDatabase(SeededDataOnlyCleanupStrategyExecutor.java:51)
          at org.jboss.arquillian.persistence.data.dbunit.DBUnitDataHandler.cleanDatabase(DBUnitDataHandler.java:190)
          at org.jboss.arquillian.persistence.data.dbunit.DBUnitDataHandler.cleanup(DBUnitDataHandler.java:122)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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.persistence.data.dbunit.DBUnitDataStateLogger.aroundCleanup(DBUnitDataStateLogger.java:108)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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.core.impl.EventImpl.fire(EventImpl.java:67)
          at org.jboss.arquillian.persistence.lifecycle.DataCleanupHandler.prepareDatabase(DataCleanupHandler.java:60)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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.persistence.data.dbunit.DBUnitPersistenceTestLifecycleHandler.createDatabaseConnection(DBUnitPersistenceTestLifecycleHandler.java:80)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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.persistence.lifecycle.ErrorCollectorHandler.createErrorCollector(ErrorCollectorHandler.java:38)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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.core.impl.EventImpl.fire(EventImpl.java:67)
          at org.jboss.arquillian.persistence.lifecycle.PersistenceTestTrigger.beforeTest(PersistenceTestTrigger.java:91)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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.before(EventTestRunnerAdaptor.java:95)
          at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:222)
          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.jmx.JMXTestRunner.runTestMethodInternal(JMXTestRunner.java:128)
          at org.jboss.arquillian.protocol.jmx.JMXTestRunner.runTestMethod(JMXTestRunner.java:107)
          at org.jboss.as.arquillian.service.ArquillianService$ExtendedJMXTestRunner.runTestMethod(ArquillianService.java:226)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:93)
          at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:27)
          at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:208)
          at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:120)
          at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:262)
          at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
          at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
          at org.jboss.as.jmx.PluggableMBeanServerImpl$TcclMBeanServer.invoke(PluggableMBeanServerImpl.java:498)
          at org.jboss.as.jmx.PluggableMBeanServerImpl.invoke(PluggableMBeanServerImpl.java:246)
          at org.jboss.remotingjmx.protocol.v1.ServerProxy$InvokeHandler.handle(ServerProxy.java:1034)
          at org.jboss.remotingjmx.protocol.v1.ServerProxy$MessageReciever$1.run(ServerProxy.java:215)
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
          at java.lang.Thread.run(Thread.java:662)
      Caused by: java.lang.NullPointerException
          at org.jboss.arquillian.persistence.data.dbunit.cleanup.SeededDataOnlyCleanupStrategyExecutor.cleanupDatabase(SeededDataOnlyCleanupStrategyExecutor.java:46)
          ... 160 more
      

       

      And all I wanted was a transaction.

       

       

      Regards,

      htfv (Aliaksei Lahachou)

        • 1. Re: Why does Persistence Extension require data source configuration?
          Bartosz Majsak Master

          Hi Aliaksei,

           

          first of all apologies for giving you a hard time with APE Going to the merrit - handling datasource definition in current version of APE is something I'm not very proud of to be honest, there is already a feature request in JIRA to make it better

          https://issues.jboss.org/browse/ARQ-899. Also support for multiple data sources is currently on the roadmap. Datasource is used only by DBUnit for seeding database for you.

           

          I totally agree that supporting transaction for the test should not require from the user specifying data source. To be honest APE should not provide transactional feature at all since it's not its' core responsibility anyway. Therefore there is ongoing effort to create Arquillian Transaction Extension which will provide just that [using different "adapter" such as plain JTA or Spring].

           

          With regards to Invalid object name 'trace_xe_event_map'. Your assumption is correct - DBUnit purge the whole database (that's the default behaviour - STRICT). You can disabe cleanup entirely using @Cleanup(phase = NONE) annotation for instance.

           

          Famous NullPointerException (last stacktrace) on the other hand has been fixed already and will be delivered with the next version. Workaround for Alpha 4 is to change cleanup execution phase from BEFORE to AFTER the test.

           

          Best regards,

          Bartosz

          1 of 1 people found this helpful
          • 2. Re: Why does Persistence Extension require data source configuration?
            Aliaksei Lahachou Newbie

            Therefore there is ongoing effort to create Arquillian Transaction Extension which will provide just that [using different "adapter" such as plain JTA or Spring].

             

            Is there something that I can try?

            • 4. Re: Why does Persistence Extension require data source configuration?
              Bartosz Majsak Master

              Hi Aliaksei,

               

              In case you haven't noticed - it's been shipped with Alpha 5

              • 5. Re: Why does Persistence Extension require data source configuration?
                jfrenetic Newbie

                Hi, Bartosz!

                 

                To be honest APE should not provide transactional feature at all since it's not its' core responsibility anyway.

                 

                Did you mean, that by default @Test method should not interact with database, unless specified? If yes, then this is very nice. Because, at first time, I was surprised, when I found out, that all @Test methods expect @DataSource to be defined and clean the database entirely. Sometimes, it's useful to have a couple of setup/teardown methods, that don't interact with the database.

                 

                 

                Also support for multiple data sources is currently on the roadmap.

                 

                Oh, this is a very valuable feature, that I'd like to have in our tests. In our application we have 2 databases, and I need to write a couple of methods like these:

                 

                @Test
                @Cleanup(phase = NONE)
                @ApplyScriptBefore("init_script1.sql")
                @DataSource("db1")
                public void initFirstDB() { }
                
                @Test
                @Cleanup(phase = NONE)
                @ApplyScriptBefore("init_script2.sql")
                @DataSource("db2")
                public void initSecondDB() { }
                

                 

                Something like this would be awesome:

                 

                @Test
                @Cleanup(phase = NONE)
                @ApplyScriptOne(script = "init_script1.sql", on = "db1")
                @ApplyScriptTwo(script = "init_script2.sql", on = "db2")
                public void initDB() { }
                

                 

                I'm not sure what would be the best way to declare something like that

                 

                P.S. sorry for off-topic question, but is there a roadmap for APE?

                • 6. Re: Why does Persistence Extension require data source configuration?
                  Bartosz Majsak Master

                   

                  Did you mean, that by default @Test method should not interact with database, unless specified? If yes, then this is very nice. Because, at first time, I was surprised, when I found out, that all @Test methods expect @DataSource to be defined and clean the database entirely. Sometimes, it's useful to have a couple of setup/teardown methods, that don't interact with the database.

                   

                  Not at all It should be still using the same convention but implementatiokn should be moved to the transaction-extension. Also cleaning up the database for each test is in my eyes quite handy assumption, because then each test is "isolated". @DataSource is not required anymore if you have single one. In case of two or more you need to specify it to give DBUnit a hint which one you are intending to use. Haven't found any smart approach yet to free you from this additional ceremony.

                   

                   

                  Something like this would be awesome:

                   

                  @Test
                  @Cleanup(phase = NONE)
                  @ApplyScriptOne(script = "init_script1.sql", on = "db1")
                  @ApplyScriptTwo(script = "init_script2.sql", on = "db2")
                  public void initDB() { }
                  

                   

                  I'm not sure what would be the best way to declare something like that

                  Some sort of "composite annotation" like @ApplyScripts( { @ApplyScript(...), @ApplyScript(...) } ) might be one way (with additional value for specifying datasource, as in your example).

                   

                   

                  P.S. sorry for off-topic question, but is there a roadmap for APE?

                  Roadmap is not really formalized and it's totally open for community to shape the direction. Some things are already in JIRA, others (mainly ideas) are gathered in this thread. Some are on my mind map, but this I will put somewhere (maybe in the mentioned thread if they are still open for discussion, where others I will add to JIRA, like multiple datasources).

                   

                  Cheers and thanks for great feedback!

                  • 7. Re: Why does Persistence Extension require data source configuration?
                    jfrenetic Newbie

                    Hi, Bartosz!

                    Also cleaning up the database for each test is in my eyes quite handy assumption, because then each test is "isolated".

                    I agree, but something like schema filter is very important here. Otherwise, DBUnit tries to delete the entire database, including system tables as well (at least in case with Oracle).

                    Some sort of "composite annotation" like @ApplyScripts( { @ApplyScript(...), @ApplyScript(...) } ) might be one way (with additional value for specifying datasource, as in your example).

                    Oh, yes, silly me

                    Roadmap is not really formalized and it's totally open for community to shape the direction.

                    Cool!

                     

                    Some things are already in JIRA, others (mainly ideas) are gathered in this thread

                     

                    Nice link, thank! Adding to bookmarks

                     

                    Cheers and thanks for great feedback!

                     

                    Thank YOU for such quick responses!

                    Cheers!

                    • 8. Re: Why does Persistence Extension require data source configuration?
                      Bartosz Majsak Master

                      Anton Shaykin wrote:

                      Also cleaning up the database for each test is in my eyes quite handy assumption, because then each test is "isolated".

                      I agree, but something like schema filter is very important here. Otherwise, DBUnit tries to delete the entire database, including system tables as well (at least in case with Oracle).

                       

                      Now you can choose between three strategies provided by DBUnit:

                       

                      STRICT

                      Cleans the entire database. This strategy might require turning off database constraints (e.g. referential integrity).

                      USED_ROWS_ONLY

                      Deletes only those entries which were defined in data sets used for seeding.

                      USED_TABLES_ONLY

                      Deletes only those tables which were used in data sets.

                      You can also specify when you would like to invoke the cleanup procedure. For instance:

                       

                      @Cleanup(phase = TestExecutionPhase.AFTER, strategy = CleanupStrategy.USED_ROWS_ONLY)

                      If you have some other ideas for schema filtering (in particular for strict) please let me know. On the other hand you can specify which schema you want to use by dbunit using "schema" property in arquillian.xml

                       

                      This should be explained somewhere in the docs

                       

                      Cheers,

                      Bartosz