7 Replies Latest reply on Jul 11, 2014 7:55 AM by javapapo

    Deployable Datasource + driver deployment in one go? Wildfly 8.1 / Arquillian

    javapapo

      Hi I am trying to figure out (maybe I am doing something wrong in the -ds.xml configuration).

       

      If Wildfly 8.1 supports the deployment of a datasource definition (ironjacamar.org/doc/schema/datasources_1_1.xsd) + a driver in one deployable package at once?

       

       

      Deployment
          public static WebArchive createDeployment() {
              File[] libs = Maven.resolver().loadPomFromFile("pom.xml").resolve("postgresql:postgresql").withTransitivity().asFile();
      
              return ShrinkWrap.create(WebArchive.class,"test.war")
                      .addAsWebInfResource("web.xml")
                      .addAsWebInfResource("test-ds.xml")
                      .addClass(SimpleUser.class)
                      .addAsResource("test-persistence.xml", "META-INF/persistence.xml")
                      .addAsLibraries(libs)
                      .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
          }
      

       

       

      At the same time is there any reference example on 1.1 xsd based -ds.xml?  I can read here, that you need to have a driver already installed which is not my case in this Arquillian test.

       

      Any tips?

        • 1. Re: Deployable Datasource + driver deployment in one go? Wildfly 8.1 / Arquillian
          maeste

          Could you please attach your test-ds.xml?

          And could you provide which version of postgres are you using?

           

          regards

          S.

          • 2. Re: Re: Deployable Datasource + driver deployment in one go? Wildfly 8.1 / Arquillian
            javapapo

            Hello Stefano, so here is my case:

             

            The Datasource definition as is in the web.xml is working fine,I am listing it below just to have something to compare.

             

            <web-app xmlns="http://java.sun.com/xml/ns/javaee"
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
                     version="3.0">
                <data-source>
                    <name>java:jboss/datasources/testpostgre</name>
                    <class-name>org.postgresql.xa.PGXADataSource</class-name>
                    <server-name>localhost</server-name>
                    <database-name>papodb</database-name>
                    <user>papo</user>
                    <password>papo</password>
                    <transactional>true</transactional>
                </data-source>
            </web-app>
            
            

             

            The postgresql driver I am actually loading from my pom (see above)

             

            postgresql:postgresql9.1-901-1.jdbc4

             

            My ds.xml file is the following- I think the drivers tag is not valid, if this is true, then according to the note in the documentation you can not deploy a datasource on the fly referencing a driver at same time? By the way some examples or notes on the 1_1 xsd would help (in the documentation).

             

            <datasources xmlns="http://www.jboss.org/ironjacamar/schema"
                         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                         xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_1.xsd">
            <datasource jndi-name="java:jboss/datasources/testpostgre" pool-name="testpostgre" enabled="true" use-java-context="true">
                <connection-url>jdbc:postgresql://localhost:5432/papodb</connection-url>
                <driver>postgresql</driver>
                <security>
                    <user-name>papo</user-name>
                    <password>papo</password>
                </security>
                <driver-class>org.postgresql.xa.PGXADataSource</driver-class>
                <!-- the drivers tag is not valid with this XSD-->
                <drivers>
                    <driver>
                        <driver name="postgresql" module="org.postgresql">
                            <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
                        </driver>
                    </driver>
                </drivers>
            </datasource>
            </datasources>
            
            

             

            Many thanks!

            • 3. Re: Deployable Datasource + driver deployment in one go? Wildfly 8.1 / Arquillian
              ctomc

              Any reason why you don't use http://docs.oracle.com/javaee/7/api/javax/annotation/sql/DataSourceDefinition.html ?

              as this is the portable way of using defining deployable data sources which are most useful for testing.

              • 4. Re: Deployable Datasource + driver deployment in one go? Wildfly 8.1 / Arquillian
                javapapo

                My case was unit tests using arquillian. I wanted to decouple the DS definition from code or annotations and leverage (if it works) the ability to package one extra file, which can me altered using maven properties prior to deployment.

                • 5. Re: Deployable Datasource + driver deployment in one go? Wildfly 8.1 / Arquillian
                  ctomc

                  Class that has @DatasourceDefinition can be part of test case only, you just add it as extra class to when you are creating deployment.

                  There is no need for your application code to have this annotation as well.

                  1 of 1 people found this helpful
                  • 6. Re: Deployable Datasource + driver deployment in one go? Wildfly 8.1 / Arquillian
                    bmajsak

                    So what's the outcome javaneze ? Can you share your solution and we can close this thread?

                    • 7. Re: Deployable Datasource + driver deployment in one go? Wildfly 8.1 / Arquillian
                      javapapo

                      Hi, I think there is no outcome, it seems that Wildfly 8.1 does not support my case as, indicated in my original post. You can use workarounds (like I did, defining the DS in an JavaEE descriptio (ear or war level).