1 Reply Latest reply on Nov 10, 2012 6:39 AM by Vineet Reynolds

    Arquillian persistence tutorial with Weblogic and H2

    Mehdi Heidarzadeh Newbie


      I checked out Aqruillain persistence tutorial and run it using glassfish embeded and with both derby and h2, it works.

      But because I need to test my code with weblogic (and h2) too, I tried running the example in weblogic too.


      I added following profile to my pom.xml:




      Then added following lines to arquillian.xml


              <property name="deploymentExportPath">target/arquillian</property>
      <container qualifier="wls" default="true">
                  <property name="adminUrl">t3://localhost:7001</property>
                  <property name="adminUserName">weblogic</property>
                  <property name="adminPassword">12345678</property>
                  <property name="target">AdminServer</property>
                  <property name="wlsHome">/opt/weblogic_server11/wlserver</property>



      then i added persistence file to /resources-weblogic/test-persistence.xml


      <persistence-unit name="test" transaction-type="JTA">
                  <property name="javax.persistence.jdbc.driver" value="org.h2.jdbcx.JdbcDataSource"/>
                  <property name="javax.persistence.jdbc.url" value="jdbc:h2:file:target/databases/h2/db"/>
                  <property name="javax.persistence.jdbc.user" value="sa"/>
                  <property name="javax.persistence.jdbc.password" value=""/>
                  <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
                  <property name="eclipselink.logging.level.sql" value="FINE"/>
                  <property name="eclipselink.logging.parameters" value="true"/>


      After running the test I got following error :


      Exception Description: PersistenceUnitInfo test has transactionType JTA, but does not have a jtaDataSource defined.


      Then I changed transaction-type="JTA" to transaction-type="RESOURCE_LOCAL" and tested again and got following error:


      Exception Description: Configuration error.  Class [org.h2.jdbcx.JdbcDataSource] not found.


      After that I checked "target/arquillian" path to see that what arquillian has generated  and saw that it has not packaged h2 jar file in generated war file! shouldn't arquillian package h2 in my war file?


      Then I copied h2 jar file in lib directory of my weblogic domain and wanted to start weblogic and test it, but weblogic did not start and I got some OSGi related errors!


      Can anyone help me with this error?

      Or, can you add a profile for weblogic and h2 in example of, arquillian persistence tutorial?

        • 1. Re: Arquillian persistence tutorial with Weblogic and H2
          Vineet Reynolds Apprentice

          The error appears to indicate that WLS could not locate and load the JDBC driver associated with H2. Since WLS does not ship with the certain database drivers, you need to configure it to load third-party JDBC drivers. The directions for doing so is provided in the Oracle documentation.


          You may also need to revert your persistence-unit to using a JTA datasource (and also configure a JTA datasource in WLS), since the Arquillian Persistence Extension relies on access to a datasource for loading and verifying data. If you use a resource-local persistence unit, it will not participate in the transaction(s) initiated in the container. This may result in test failures especially if the transaction management semantics of the resource-local PU conflicts with the semantics used by the persistence extension. For example, if the PU does not commit it's transactions, but APE expects to read committed data, then verification of datasets (expressed in the @ShouldMatchDataSet annotations) would fail.