Could you please attach your test-ds.xml?
And could you provide which version of postgres are you using?
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)
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>
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.
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.
1 of 1 people found this helpful
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.
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).