1 Reply Latest reply on Aug 29, 2013 9:10 AM by Bartosz Majsak

    Problem with execute sql script

    lukas lukasz Newbie

      Hello

      i am confiusing i try all option to load sql script but i have got always exception.

       

      So for tests i am using :

       

       

              <dependency>
                  <groupId>org.jboss.arquillian.container</groupId>
                  <artifactId>arquillian-glassfish-embedded-3.1</artifactId>
                  <version>1.0.0.CR3</version>
                  <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>
      

       

      and this is my 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">
          <container qualifier="glassfish-embedded" default="true">
              <configuration>
                  <property name="sunResourcesXml">
                      src/test/resources/glassfish-resources.xml                
                  </property>
                  <property name="allowConnectingToRunningServer">true</property>
                  <property name="bindHttpPort">9999</property>
              </configuration> 
          </container>
          
          <!-- see: https://docs.jboss.org/author/display/ARQ/Persistence#Persistence-dbunitsettings -->
          
          <extension qualifier="persistence-dbunit">
            <property name="defaultDataSetLocation">datasets/</property>
          </extension>
          
          <extension qualifier="persistence-script">
           <!--  <property name="scriptsToExecuteBeforeTest">scripts/import.sql</property> -->
            <property name="defaultSqlScriptLocation">scripts/</property>
          </extension>   
          
          <extension qualifier="persistence">
              <property name="defaultDataSource">test-ds</property>
          </extension>
      </arquillian>
      

       

       

      and my database derby :

      <resources>
          <jdbc-connection-pool name="test-pool"
              res-type="javax.sql.DataSource" datasource-classname="org.apache.derby.jdbc.EmbeddedDataSource"
              ping="true">
              <property name="ConnectionAttributes" value="create=true" />
              <property name="DatabaseName" value="./target/derbydb" />
              <property name="Password" value="" />
              <property name="User" value="" />
          </jdbc-connection-pool>
          <jdbc-resource jndi-name="test-ds" pool-name="test-pool" />
      </resources>
      

       

       

      so everything is fine for me my datasets working fine but not sql script : /

       

      this is my simply script:

      CREATE TABLE ofconversation
      (
        conversationid integer NOT NULL,
        room character varying(1024),
        isexternal smallint NOT NULL,
        startdate bigint NOT NULL,
        lastactivity bigint NOT NULL,
        messagecount integer NOT NULL,
        CONSTRAINT ofconversation_pk PRIMARY KEY (conversationid)
      );
      

       

      its all ant i also install squirell and try to run that script in embedded derby and everything fine so whots i wrong ???

       

      i try load script using :

       

       

      @RunWith(Arquillian.class)
      @PersistenceTest
      @CreateSchema
      @UsingDataSet({ "datasets/pairchat.xml", "datasets/groupchat.xml" })
      @Transactional(value = TransactionMode.DISABLED)
      public class PairChatTest {
      

       

      also try:

      @CreateSchema(scripts/import.sql)

      @ApplyScriptBefore

       

      and also :<property name="scriptsToExecuteBeforeTest">scripts/import.sql</property>;

       

      but i have got errror and i do not now why and what is wrong???

       

       

      Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 8.576 sec <<< FAILURE!
      test2(pl.pisystem.ejb.im.service.impl.PairChatTest)  Time elapsed: 0.428 sec  <<< ERROR!
      org.jboss.arquillian.persistence.dbunit.exception.DBUnitDataSetHandlingException: Unable to execute statement: CREATE TABLE OFCONVERSATION
      (
      CONVERSATIONID integer NOT NULL,
      ROOM character varying(1024),
      ISEXTERNAL smallint NOT NULL,
      STARTDATE bigint NOT NULL,
      LASTACTIVITY bigint NOT NULL,
      MESSAGECOUNT integer NOT NULL,
      CONSTRAINT OFCONVERSATION_PK PRIMARY KEY (CONVERSATIONID)
      );
          at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
          at org.apache.derby.impl.sql.compile.ParserImpl.parseStatement(Unknown Source)
          at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source)
          at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source)
          at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown Source)
          at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
          at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
          at com.sun.gjc.spi.base.StatementWrapper.execute(StatementWrapper.java:359)
          at org.jboss.arquillian.persistence.script.ScriptExecutor.executeStatement(ScriptExecutor.java:130)
          at org.jboss.arquillian.persistence.script.ScriptExecutor.execute(ScriptExecutor.java:115)
          at org.jboss.arquillian.persistence.dbunit.DBUnitDataHandler.executeScript(DBUnitDataHandler.java:144)
          at org.jboss.arquillian.persistence.dbunit.DBUnitDataHandler.executeScripts(DBUnitDataHandler.java:132)
          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.persistence.core.lifecycle.CustomScriptsExecutor.executeScriptsBeforeTest(CustomScriptsExecutor.java:72)
          at org.jboss.arquillian.persistence.core.lifecycle.CustomScriptsExecutor.executeBeforeTest(CustomScriptsExecutor.java:57)
          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.persistence.dbunit.DBUnitDataStateLogger.beforePersistenceTest(DBUnitDataStateLogger.java:98)
          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.persistence.core.lifecycle.SchemaCreationScriptsExecutor.createSchema(SchemaCreationScriptsExecutor.java:68)
          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.persistence.dbunit.DBUnitPersistenceTestLifecycleHandler.createDatasets(DBUnitPersistenceTestLifecycleHandler.java:108)
          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.persistence.core.lifecycle.ErrorCollectorHandler.createErrorCollector(ErrorCollectorHandler.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.proceed(EventContextImpl.java:88)
          at org.jboss.arquillian.persistence.dbunit.DBUnitPersistenceTestLifecycleHandler.provideDatabaseConnection(DBUnitPersistenceTestLifecycleHandler.java:118)
          at org.jboss.arquillian.persistence.dbunit.DBUnitPersistenceTestLifecycleHandler.provideDatabaseConnectionAroundBeforePersistenceTest(DBUnitPersistenceTestLifecycleHandler.java:84)
          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.core.impl.EventImpl.fire(EventImpl.java:67)
          at org.jboss.arquillian.persistence.core.lifecycle.PersistenceTestTrigger.beforeTest(PersistenceTestTrigger.java:113)
          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.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:69)
          at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)
          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:292)
          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:668)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
          at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
          at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
          at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
          at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
          at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
          at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
          at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
          at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
          at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
          at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
          at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
          at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
          at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
          at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
          at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
          at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
          at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
          at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
          at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
          at java.lang.Thread.run(Thread.java:722)
      

       

       

      I am confiusing this sql script running in derby but not in arquillian .....