Note that you may instead deploy the PostgreSQL JDBC driver as a module. That's the only way you'll be able to use a -ds.xml file to define a datasource, as far as I can tell anyway.
Create the directory modules/org/postgresql/main
and place postgresql-9.1-901-1.jdbc4.jar
within it. Now create a module.xml file in the same place, with the content:
<module xmlns="urn:jboss:module:1.1" name="org.postgresql">
<!-- Load with jboss-cli command:
/subsystem=datasources/jdbc-driver=postgresql-driver:add(driver-name=postgresql-driver, driver-class-name=org.postgresql.Driver, driver-module-name=org.postgresql)
-->
<resources>
<resource-root path="postgresql-9.1-901-1.jdbc4.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Activate it as "postgresql-driver" with
jboss-cli.sh --connect command="/subsystem=datasources/jdbc-driver=postgresql-driver:add(driver-name=postgresql-driver, driver-class-name=org.postgresql.Driver, driver-module-name=org.postgresql"
You may now use this driver in -ds.xml files by specifying it as "postgresql-driver", eg:
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<datasource jndi-name="java:/datasources/some-ds" enabled="true" use-java-context="true"
pool-name="some-ds-pool">
<connection-url>jdbc:postgresql:somedb</connection-url>
<driver>postgresql-driver</driver>
<security>
<user-name>user</user-name>
<password>pass</password>
</security>
</datasource>
</datasources>
Unlike explicitly naming the jdbc jar in a data-source create command, you can now update PgJDBC without changing all your datasources.