This is in the scenario where you want JBoss to handle the datasource and transactions, for example when using injected @PersistenceContext in a @Stateless resource. I like it especially when writing REST services with JAX-RS (example code included below).
Create dir:
/modules/org/postgresql/main
Place files at these locations:
/modules/org/postgresql/main/postgresql-8.3-607.jdbc4.jar
/modules/org/postgresql/main/postgis-1.5.3.jar
Create file /modules/org/postgresql/main/module.xml with content:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="org.postgresql">
<resources>
<resource-root path="postgresql-8.3-607.jdbc4.jar"/>
<resource-root path="postgis-1.5.3.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Place files at these locations:
/modules/org/hibernate/main/hibernate-spatial-4.0-M1.jar
/modules/org/hibernate/main/jts-1.12.jar
Add this xml fragments to the resources tag in /modules/org/hibernate/main/module.xml:
<resource-root path="hibernate-spatial-4.0-M1.jar"/>
<resource-root path="jts-1.12.jar"/>
Add this xml fragment to the dependencies tag in /modules/org/hibernate/main/module.xml:
<module name="org.postgresql"/>
Finally, add this xml fragment to the drivers tag in your deployment configuration (might be /standalone/configuration/standalone.xml):
<driver name="postgresql" module="org.postgresql">
<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
</driver>
NOTE: Trying to use Hibernate Spatial for a specific deployment in WEB-INF/lib will result in classpath problems which is one reason for this how to...
Hi Viliam,
full example with WildFly 8.1 is available here: wildfly-arquillian-hibernate-spatial-postgis
Hope it helps.