0
votes

When I try to start my WildFly server, I got this error :

2018-11-17 21:29:55,203 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 33) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("jdbc-driver" => "org.postgresql")
]) - failure description: "WFLYJCA0041: Failed to load module for driver [org.postgresql]"
ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "swap")
]) - failure description: {"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.driver-demander.java:jboss/datasources/swap is missing [jboss.jdbc-driver.org_postgresql]",
"jboss.data-source.java:jboss/datasources/swap is missing [jboss.jdbc-driver.org_postgresql]"
]}
2018-11-17 21:30:07,625 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "swap")
]) - failure description: {"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.driver-demander.java:jboss/datasources/swap is missing [jboss.jdbc-driver.org_postgresql]",
"jboss.data-source.java:jboss/datasources/swap is missing [jboss.jdbc-driver.org_postgresql]",
"jboss.data-source.java:jboss/datasources/swap is missing [jboss.jdbc-driver.org_postgresql]"
]}

And my standalone.xml :

<datasources>
     <datasource jndi-name="java:jboss/datasources/swap" pool-name="swap" enabled="true" use-java-context="true">
        <connection-url>jdbc:postgresql://127.0.0.1:5432/swap?useUnicode=yes&amp;characterEncoding=UTF-8</connection-url>
        <driver>org.postgresql</driver>
        <security>
            <user-name>postgres</user-name>
            <password>postgres</password>
        </security>
     </datasource>
     <drivers>
         <driver name="org.postgresql" module="org.postgresql">
             <driver-class>org.postgresql.Driver</driver-class>
             <xa-datasource-class>org.postgresql.Driver</xa-datasource-class>
         </driver>
     </drivers>
</datasources>

My PostgreSQL module.xml :

<?xml version="1.0" encoding="UTF-8"?>  
<module xmlns="urn:jboss:module:1.1" name="org.postgresql">  
    <resources>  
        <resource-root path="postgresql-42.2.5.jar"/>  
    </resources> 
        <module name="javax.api"/>  
        <module name="javax.transaction.api"/>  
    </dependencies>  
</module>  

What could be the problem? Please help and Thanks.

2

2 Answers

0
votes

Your module.xml is invalid. A <dependencies> tag is missing. Try it with the following:

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.postgresql">
    <resources>
        <resource-root path="postgresql-42.2.5.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>
</module>

EDIT:

The module.xml file and the postgresql-42.2.5.jar have to be in

C:\wildfly\wildfly-9.0.2.Final\modules\system\layers\base\org\postgresql\main.

It is also recommended to put your modules directly into

C:\wildfly\wildfly-9.0.2.Final\modules\.

So in your case C:\wildfly\wildfly-9.0.2.Final\modules\org\postgresql\main, that can be problem.

For reference, also have a look at the EAP7 Documentation and you should also think about using the jboss-cli.

0
votes

For configuration of PostgresSQL for WildFly server, you should follow the following steps.

Step 1 : Adding PostgreSQL Module

Create new folder ${wildfly_home}/modules/system/layers/base/org/postgresql/main/ if not exist.

Download Latest Driver Jar via this link => https://jdbc.postgresql.org/download.html and put under the above folder.

Also in that new folder, Create module.xml and put the following config.

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="org.postgresql">

    <resources>
        <resource-root path="postgresql-42.2.23.jar"/>
    </resources>

    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>
            
</module>

May be jar version need to update in resource-root.

Step 2 : Update DB configs from standalone.xml

Remove Existing <driver> config and add new config as follow.

<driver name="postgresql" module="org.postgresql">
    <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
</driver>
        

Remove existing <datasource> config and add new config as follow.

<datasource jndi-name="java:jboss/datasources/PostgresDS" pool-name="PostgresDS" enabled="true" use-java-context="true">
    <connection-url>jdbc:postgresql://127.0.0.1:5432/swap?useUnicode=yes&amp;characterEncoding=UTF-8</connection-url>
    <driver>postgresql</driver>
    <security>
        <user-name>postgres</user-name>
        <password>postgres</password>
    </security>
    <pool>
        <max-pool-size>20</max-pool-size>
    </pool>
</datasource>
        

Modify default-bindings datasource name to PostgresDS from ExampleDS.

<default-bindings context-service="java:jboss/ee/concurrency/context/default" datasource="java:jboss/datasources/PostgresDS" ...

Make sure that you have created your swap database in PostgreSQL database server.

Now, run server and it will be fine.