czerny czerny - 1 year ago 703
Java Question

How to add PostgreSQL datasource to WildFly 9.0?

I've tried tutorial at

  1. ./

  2. module add --name=org.postgres --resources=/tmp/postgresql-9.3-1101.jdbc41.jar --dependencies=javax.api,javax.transaction.api

  3. /subsystem=datasources/jdbc-driver=postgres:add(driver-name="postgres",driver-module-name="org.postgres",driver-class-name=org.postgresql.Driver)

  4. data-source add --jndi-name=java:/PostGreDS --name=PostgrePool --connection-url=jdbc:postgresql://localhost/postgres --driver-name=postgres --user-name=postgres --password=postgres

This tutorial works with WildFly 8.2, but it doesn't work with WildFly 9.0. 3rd step fails with error message:

"outcome" => "failed",
"failure-description" => "WFLYJCA0041: Failed to load module for driver [org.portgres]",
"rolled-back" => true

How to add Postgres datasource to WildFly 9.0?

Answer Source

I've encountered the same error and behavior of WildFly 9. I'm a complete newbie to WF, but after some research I've found that the trouble is in the module naming. If I'm getting it well, the actual package names in the module are used to resolve the path to module.xml.
I've changed the steps to those below and it worked:

module add --name=org.postgresql --slot=main --resources=/usr/local/lib/postgresql-9.4-1201.jdbc4.jar --dependencies=javax.api,javax.transaction.api

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download