Q:

Failed to load module for driver org.postgresq

I want to use postgresql in Jboss Wildfly Swarm via declaration of datasource.
The application startup error message is:
Failed to load module for driver org.postgresq
Content of the main class:
 public static void main(String[] args) throws Exception {
            Container container = new Container();

    container.fraction(new DatasourcesFraction()
                    .jdbcDriver("postgresql", (d) -> {

      d.driverDatasourceClassName("org.postgresql.Driver");

      d.xaDatasourceClass("org.postgresql.xa.PGXADataSource");
      d.driverModuleName("org.postgresql");
                    })
    .dataSource("ExampleDS", (ds) -> {
      ds.driverName("postgresql");

      ds.connectionUrl("jdbc:postgresql://localhost:5432/test_db");
      ds.userName("sa");
      ds.password("sa");
                    })
    );
            container.start();

            JAXRSDeployment appDeployment = new JAXRSDeployment( container );
            appDeployment.addResource(MyResource.class);

            container.deploy(appDeployment);
        }

Thanks for any help

A:

Following wildfly-swarm example could be usefull.
It describes how to deploy both driver and datasource in Wildfly Swarm Container: (There are IT tests which cover it)
https://github.com/wildfly-swarm/wildfly-swarm-examples/tree/master/datasource/datasource-deployment
EDIT: datasource-deployment example documentation is not up to date, valid example here 
Here are logs when I run this example main method. Datasource deployment seems to work fine:
20:00:19,081 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final
20:00:19,491 INFO  [org.jboss.as] (MSC service thread 1-7) WFLYSRV0049: WildFly Core 2.0.0.CR8 "Kenny" starting
2015-12-05 20:00:20,683 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 16) WFLYNAM0001: Activating Naming Subsystem
2015-12-05 20:00:20,673 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 20) WFLYTX0013: Node identifier property is set to the default value. Please make sure it is unique.
2015-12-05 20:00:20,701 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 17) WFLYSEC0002: Activating Security Subsystem
2015-12-05 20:00:20,726 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 14) WFLYIO001: Worker 'default' has auto-configured to 8 core threads with 64 task threads based on your 4 available processors
2015-12-05 20:00:20,740 INFO  [org.jboss.as.naming] (MSC service thread 1-1) WFLYNAM0003: Starting Naming Service
2015-12-05 20:00:20,754 INFO  [org.jboss.as.security] (MSC service thread 1-4) WFLYSEC0001: Current PicketBox version=4.9.3.Final
2015-12-05 20:00:20,781 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0003: Undertow 1.3.3.Final starting
2015-12-05 20:00:20,783 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 13) WFLYUT0003: Undertow 1.3.3.Final starting
2015-12-05 20:00:20,812 INFO  [org.jboss.as.connector] (MSC service thread 1-2) WFLYJCA0009: Starting JCA Subsystem (WildFly/IronJacamar 1.3.1.Final)
2015-12-05 20:00:20,948 INFO  [org.xnio] (MSC service thread 1-1) XNIO version 3.3.2.Final
2015-12-05 20:00:20,979 INFO  [org.xnio.nio] (MSC service thread 1-1) XNIO NIO Implementation Version 3.3.2.Final
2015-12-05 20:00:21,071 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) WFLYUT0012: Started server default-server.
2015-12-05 20:00:21,189 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) WFLYUT0006: Undertow HTTP listener default listening on [0:0:0:0:0:0:0:0]:8080
2015-12-05 20:00:24,250 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Core 2.0.0.CR8 "Kenny" started in 5336ms - Started 106 of 113 services (18 services are lazy, passive or on-demand)
2015-12-05 20:00:24,274 ERROR [stderr] (main) found version: 1.4.187
2015-12-05 20:00:24,802 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0027: Starting deployment of "h2" (runtime-name: "h2")
2015-12-05 20:00:25,160 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-8) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.4)
2015-12-05 20:00:25,181 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) WFLYJCA0018: Started Driver service with driver-name = h2
2015-12-05 20:00:25,252 INFO  [org.jboss.as.server] (main) WFLYSRV0010: Deployed "h2" (runtime-name : "h2")
2015-12-05 20:00:25,272 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-7) WFLYSRV0027: Starting deployment of "864c873e-444b-4d35-89f4-c7b333afc3bc.jar" (runtime-name: "864c873e-444b-4d35-89f4-c7b333afc3bc.jar")
2015-12-05 20:00:25,333 WARN  [org.jboss.as.connector] (MSC service thread 1-7) WFLYJCA0091: -ds.xml file deployments are deprecated. Support may be removed in a future version.
2015-12-05 20:00:25,441 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-5) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
2015-12-05 20:00:25,507 INFO  [org.jboss.as.server] (main) WFLYSRV0010: Deployed "864c873e-444b-4d35-89f4-c7b333afc3bc.jar" (runtime-name : "864c873e-444b-4d35-89f4-c7b333afc3bc.jar")
2015-12-05 20:00:25,624 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0027: Starting deployment of "3736861a-1203-41d5-a5c3-963193b1975b.war" (runtime-name: "3736861a-1203-41d5-a5c3-963193b1975b.war")
2015-12-05 20:00:25,812 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0018: Host default-host starting
2015-12-05 20:00:26,143 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 10) RESTEASY002225: Deploying javax.ws.rs.core.Application: class org.wildfly.swarm.generated.WildFlySwarmDefaultJAXRSApplication
2015-12-05 20:00:26,186 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 10) WFLYUT0021: Registered web context: /
2015-12-05 20:00:26,273 INFO  [org.jboss.as.server] (main) WFLYSRV0010: Deployed "3736861a-1203-41d5-a5c3-963193b1975b.war" (runtime-name : "3736861a-1203-41d5-a5c3-963193b1975b.war")

Have you also added driver library to your classpath, by declaring it in your runtime dependencies if you're using maven?

