Phillip
Phillip

Reputation: 87

connection pool not working in Glassfish

I am running a Glassfish server version 4.1 in combination with Netbeans using localhost. I do this on 2 computers with Windows 10. On one computer I installed a new, clean, version of Windows 10. On that computer the connectionpool is not working. On the other computer it's working fine as well as in Linux (previous operating system).

In Netbeans I am developping a Maven web application running on a Glassfish server with the glassfis-fesources.xml file as follows:

<resources>
<jdbc-resource 
    enabled="true" 
    jndi-name="jdbc/securityDatasource" 
    object-type="user" 
    pool-name="jdbcRealmPool">
    <description/>
</jdbc-resource>
<jdbc-connection-pool 
    allow-non-component-callers="false" 
    associate-with-thread="false" 
    connection-creation-retry-attempts="0" 
    connection-creation-retry-interval-in-seconds="10" 
    connection-leak-reclaim="false" 
    connection-leak-timeout-in-seconds="0" 
    connection-validation-method="auto-commit" 
    datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource" 
    fail-all-connections="false" idle-timeout-in-seconds="300" 
    is-connection-validation-required="false" 
    is-isolation-level-guaranteed="true" 
    lazy-connection-association="false" 
    lazy-connection-enlistment="false" 
    match-connections="false" 
    max-connection-usage-count="0" 
    max-pool-size="32" 
    max-wait-time-in-millis="60000" 
    name="jdbcRealmPool" 
    non-transactional-connections="false" 
    pool-resize-quantity="2" 
    res-type="javax.sql.ConnectionPoolDataSource" 
    statement-timeout-in-seconds="-1" 
    steady-pool-size="8" 
    validate-atmost-once-period-in-seconds="0" 
    wrap-jdbc-objects="false">
    <property name="User" value="admin_computat"/>
    <property name="Password" value="*****"/>
    <property name="ServerName" value="localhost"/>
    <property name="Port" value="3306" />
    <property name="DatabaseName" value="admin_computat" />
     <property name="Url" value="jdbc:mysql://localhost:3306/admin_computat"/>
</jdbc-connection-pool>

On the machine, with the new Windows 10 installation, I got the following error while while I do a ping test in Glassfish.

Warning: RAR8054: Exception while creating an unpooled [test] connection for pool [ jdbcRealmPool ], Exception while destroying physical connection Severe: RestResponse.getResponse() gives FAILURE. endpoint = 'http://localhost:4848/management/domain/resources/ping-connection-pool.json'; attrs = '{id=jdbcRealmPool}'

It is possible to make a connection with the database in Netbeans with the same properties.

Why is the connectionpool not working?

edit: clicking on http://localhost:4848/management/domain/resources/ping-connection-pool.json I found this message.

{"message":"Cannot find poolName in ping-connection-pool command model, file a bug\ninjection failed on org.glassfish.connectors.admin.cli.PingConnectionPool.poolName with class java.lang.String","command":"ping-connection-pool command","exit_code":"FAILURE","extraProperties":{"methods":[{"name":"GET"},{"messageParameters":{"appname":{"acceptableValues":"","defaultValue":"","optional":"true","type":"string"},"id":{"acceptableValues":"","defaultValue":"","optional":"false","type":"string"},"modulename":{"acceptableValues":"","defaultValue":"","optional":"true","type":"string"},"targetName":{"acceptableValues":"","defaultValue":"","optional":"true","type":"string"}}}],"commandLog":["ping-connection-pool"]},"children":[{"message":"Usage: ping-connection-pool [--appname=appname] [--modulename=modulename] pool_name ","properties":{}}]}

Upvotes: 2

Views: 9861

Answers (2)

LuisDeveloper
LuisDeveloper

Reputation: 41

Blockquote Maybe someone can give an answer why the same project isn't working at one computer.

Blockquote

Probably because the first computer already had a "MysqlConnectionPoolDataSource", and the second computer, didn't.

Jokes away, the names of JDBC connection pools, and JDBC resources, must be unique. So if one name is repeated, an error appears.

Upvotes: 0

Phillip
Phillip

Reputation: 87

I found the problem:

The configuration file glassfish-resource.xml had the following setting:

datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource"

I changed it in

datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"

and now it's working.

Maybe someone can give an answer why the same project isn't working at one computer.

Upvotes: 3

Related Questions