WFLYCTL0412: Required services that are not instal

2019-03-24 14:22发布

问题:

I'm trying to add a datasource in Wildfly 10.0, but when i test connection this the error message that throws:

Unexpected HTTP response: 500

Request
{
    "address" => [
        ("subsystem" => "datasources"),
        ("data-source" => "PostgreCrawlazo")
    ],
    "operation" => "test-connection-in-pool"
}

Response

Internal Server Error
{
    "outcome" => "failed",
    "failure-description" => "WFLYJCA0040: failed to invoke operation: WFLYJCA0042: failed to match pool. Check JndiName: java:/crawlazo",
    "rolled-back" => true,
    "response-headers" => {"process-state" => "reload-required"}
}

The error from the server log:

2016-09-01 16:28:40,524 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("data-source" => "PostgreCrawlazo")
]) - failure description: {
    "WFLYCTL0412: Required services that are not installed:" => [
        "jboss.jdbc-driver.postgres",
        "jboss.jdbc-driver.postgres"
    ],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => [
        "jboss.driver-demander.java:/crawlazo is missing [jboss.jdbc-driver.postgres]",
        "org.wildfly.data-source.PostgreCrawlazo is missing [jboss.jdbc-driver.postgres]",
        "org.wildfly.data-source.PostgreCrawlazo is missing [jboss.jdbc-driver.postgres]"
    ]
}

i'm replicating the same configuration files from standalone.xml and module.xml

here is part how i set up the datasource in standalone.xml:

 <datasource jndi-name="java:/crawlazo" pool-name="PostgreCrawlazo" enabled="true">
                    <connection-url>jdbc:postgresql://x.x.x.x:5432/crawlazo</connection-url>
                    <driver>postgres</driver>
                    <pool>
                        <min-pool-size>1</min-pool-size>
                        <max-pool-size>40</max-pool-size>
                    </pool>
                    <security>
                        <user-name>someUser</user-name>
                        <password>somePasswd</password>
                    </security>
                </datasource>
                <drivers>
                    <driver name="h2" module="com.h2database.h2">
                        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                    </driver>
                    <driver name="postgres" module="org.postgres">
                        <driver-class>org.postgresql.Driver</driver-class>
                    </driver>
            </drivers>

and the module.xml:

<module xmlns="urn:jboss:module:1.0" name="org.postgresql">
    <resources>
        <resource-root path="postgresql-9.2-1004.jdbc3.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>
</module>

I have a postgresql-9.2-1004.jdbc3.jar in the deployment folder.

Why this error appears? what i could have forgotten to config?

回答1:

The driver jar should be in the module folder not in the deployment folder as you are implying this when you wrote :

<resources>
    <resource-root path="postgresql-9.2-1004.jdbc3.jar"/>
</resources>


回答2:

I got mine working like this:

1 - create a folder in the WildFly installation dir: \modules\org\postgres\main

2 - create a "module.xml" in the folder above with the content:

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

    <resources>
        <resource-root path="postgresql-9.4-1204-jdbc4.jar"/>
    </resources>

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

3 - copy the driver JAR file to the same folder of step 1

4 - add the datasource in standalone.xml:

<datasource jta="false" jndi-name="java:jboss/datasources/YourDS" pool-name="YourDS" enabled="true" use-ccm="false">
    <connection-url>jdbc:postgresql://localhost:5432/yourDB</connection-url>
    <driver>postgres</driver>
    <security>
        <user-name>user</user-name>
        <password>pass/password>
    </security>
    <validation>
        <validate-on-match>false</validate-on-match>
        <background-validation>false</background-validation>
    </validation>
    <statement>
        <share-prepared-statements>false</share-prepared-statements>
    </statement>
</datasource>

<drivers>
    <driver name="postgres" module="org.postgres">
        <driver-class>org.postgresql.Driver</driver-class>
    </driver>
</drivers>


回答3:

This was the way I created my xa-datasources with jboss-cli console:

First, I added the driver on /opt/wildfly/modules/system/layers/base/org/postgresql/main. Notice I created the file for the driver module but I also added the jar

[root@localhost main]# ls -lrta
total 776
drwxr-xr-x. 3 root    root        18 abr  4 17:10 ..
-rwxr-xr-x. 1 wildfly wildfly 790405 abr  4 17:14 postgresql-42.2.2.jar
-rwxr-xr-x. 1 wildfly wildfly    278 abr 17 17:25 module.xml
drwxr-xr-x. 2 root    root        53 abr 17 19:40 .
[root@localhost main]# cat 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.2.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>

Next, I created the datasource on console

jboss-cli.sh --connect --controller=192.168.119.116:9990 --commands='xa-data-source add --name=FrontEndDSXA --profile=full --driver-name="postgresql" --enabled="true" --use-ccm="true" --jndi-name="java:jboss/datasources/FrontEndDSXA" --user-name="user" --password="password" --validate-on-match=true --background-validation=false --prepared-statements-cache-size=50 --share-prepared-statements=true --min-pool-size=5 --max-pool-size=150 --pool-prefill=true --transaction-isolation=TRANSACTION_READ_COMMITTED --check-valid-connection-sql="select 1;" --xa-datasource-properties={ "DatabaseName"=>"frontend", "PortNumber"=>"5432", "ServerName"=>"192.168.119.114" }'

Next, added the profile full to my-server-group on domain.xml

<server-groups>
    <server-group name="my-server-group" profile="full">
        <jvm name="default">
            <heap size="64m" max-size="512m"/>
        </jvm>
        <socket-binding-group ref="full-sockets"/>
    </server-group>
</server-groups>

Finally, I reloaded Wildfly (in my case, host was master as default)

/opt/wildfly/bin/jboss-cli.sh --connect --controller=192.168.119.116:9990 --commands="reload --host=master"

Now, all the servers on my-server-group, can see the datasource.

Hope it helps



标签: wildfly