Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wildfly 10 can't connect datasource: invalid connection

Problem

I'm trying test my connection and it keeps giving me the same error while at first sight I can't see what I did wrong. Maybe I'm overlooking something...

Error

    nexpected HTTP response: 500

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

    Response

    Internal Server Error
    {
        "outcome" => "failed",
        "failure-description" => "WFLYJCA0040: failed to invoke operation: WFLYJCA0047: Connection is not valid",
        "rolled-back" => true
    }


Standalone-full.xml

    <subsystem xmlns="urn:jboss:domain:datasources:4.0">
                <datasources>
                    <datasource jta="true" jndi-name="java:/ProjectenDS" pool-name="ProjectenDS" enabled="true" use-ccm="true">
                        <connection-url>jdbc:mysql://localhost:3306/projecten3db</connection-url>
                <driver-class>com.mysql.jdbc.Driver</driver-class>
                <driver>mysql-connector-java-5.1.40-bin.jar_com.mysql.jdbc.Driver_5_1</driver>
                <pool>
                    <min-pool-size>10</min-pool-size>
                    <initial-pool-size>11</initial-pool-size>
                    <max-pool-size>100</max-pool-size>
                </pool>
                <security>
                    <user-name>projecten</user-name>
                    <password>projecten</password>
                </security>
                <validation>
                    <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
                    <background-validation>true</background-validation>
                    <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
                </validation>
            </datasource>
        </datasources>
    </subsystem>
like image 529
Freki Avatar asked Nov 10 '16 22:11

Freki


3 Answers

If your datasource is not XA, open standalone.xml and remove the datasource-class property from your datasource definition. Wildfly adds it even if you don't specify it whe you create the datasource.

You may have to restart the server to see it working.

like image 187
Prefijo Sustantivo Avatar answered Nov 08 '22 17:11

Prefijo Sustantivo


The exception you have is generic.

Check on {WILDFLY_HOME}/standalone/log/server.log

You can use tail -f server.log while you test on the web console.

This will give you the right error to work on.

like image 37
user2543120 Avatar answered Nov 08 '22 16:11

user2543120


I solved this error by reducing pool size and set prefill attribute to false on datasource settings.

<pool>
   <min-pool-size>5</min-pool-size>
   <max-pool-size>10</max-pool-size>
   <prefill>false</prefill>
   <use-strict-min>false</use-strict-min>
   <flush-strategy>IdleConnections</flush-strategy>
</pool>
like image 1
rodrigomelo Avatar answered Nov 08 '22 18:11

rodrigomelo