[GLASSFISH-11821] poor error message from create-jdbc-connection-pool Created: 24/Apr/10  Updated: 02/Nov/10

Status: Reopened
Project: glassfish
Component/s: jdbc
Affects Version/s: v3.0.1
Fix Version/s: 3.1_ms07

Type: Bug Priority: Minor
Reporter: vince kraemer Assignee: Jagadish
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Issuezilla Id: 11,821

 Description   

Here is the output that I get from 3.0.1 b12

vkraemer$ ../../GlassFish3.0.1.b12/glassfish/bin/asadmin create-jdbc-connection-pool foobar
com.sun.enterprise.admin.cli.CommandException: remote failure: JDBC connection pool foobar creation
failed. Constraints for this bean violated.
Message = Must specify a datasource/driver classname. DatasourceClassname is mandatory when
resType is javax.sql.DataSource/javax.sql.ConnectionPoolDataSource/javax.sql.XADataSource.
DriverClassname is mandatorywhen resType is java.sql.Driver.

Command create-jdbc-connection-pool failed.

Here is the output that I expected....

vkraemer$ ../../GlassFish3.0.1.b12/glassfish/bin/asadmin create-jdbc-connection-pool foobar
com.sun.enterprise.admin.cli.CommandException: remote failure: JDBC connection pool foobar creation
failed. Constraints for this bean violated.
Message = Must specify a datasource/driver classname. DatasourceClassname is mandatory when
resType is javax.sql.DataSource/javax.sql.ConnectionPoolDataSource/javax.sql.XADataSource.
DriverClassname is mandatorywhen resType is java.sql.Driver.
Usage: asadmin [asadmin-utility-options] create-jdbc-connection-pool
[--datasourceclassname <datasourceclassname>] [--restype <restype>]
[--steadypoolsize <steadypoolsize>] [--maxpoolsize <maxpoolsize>]
[--maxwait <maxwait>] [--poolresize <poolresize>]
[--idletimeout <idletimeout>] [--initsql <initsql>]
[--isolationlevel <isolationlevel>]
[--isisolationguaranteed[=<isisolationguaranteed(default:true)>]]
[--isconnectvalidatereq[=<isconnectvalidatereq(default:false)>]]
[--validationmethod <validationmethod>]
[--validationtable <validationtable>]
[--failconnection[=<failconnection(default:false)>]]
[--allownoncomponentcallers[=<allownoncomponentcallers(default:false)>]]
[--nontransactionalconnections[=<nontransactionalconnections(default:false)>]]
[--validateatmostonceperiod <validateatmostonceperiod>]
[--leaktimeout <leaktimeout>]
[--leakreclaim[=<leakreclaim(default:false)>]]
[--creationretryattempts <creationretryattempts>]
[--creationretryinterval <creationretryinterval>]
[--sqltracelisteners <sqltracelisteners>]
[--statementtimeout <statementtimeout>]
[--lazyconnectionenlistment[=<lazyconnectionenlistment(default:false)>]]
[--lazyconnectionassociation[=<lazyconnectionassociation(default:false)>]]
[--associatewiththread[=<associatewiththread(default:false)>]]
[--driverclassname <driverclassname>]
[--matchconnections[=<matchconnections(default:false)>]]
[--maxconnectionusagecount <maxconnectionusagecount>]
[-ping[=<ping(default:false)>]] [-pooling[=<pooling(default:true)>]]
[--statementcachesize <statementcachesize(default:0)>]
[--validationclassname <validationclassname>]
[--wrapjdbcobjects[=<wrapjdbcobjects(default:true)>]]
[--description <description>] [--property <property>]
[--target <target>] [?|-help[=<help(default:false)>]]
jdbc_connection_pool_id
Command create-jdbc-connection-pool failed.

The error would be even better if it said this

com.sun.enterprise.admin.cli.CommandException: remote failure: JDBC connection pool foobar creation
failed.
Message = Must specify a datasource/driver classname. The option --datasourceclassname or –
driverclassname is mandatory.

instead of this

com.sun.enterprise.admin.cli.CommandException: remote failure: JDBC connection pool foobar creation
failed. Constraints for this bean violated.
Message = Must specify a datasource/driver classname. DatasourceClassname is mandatory when
resType is javax.sql.DataSource/javax.sql.ConnectionPoolDataSource/javax.sql.XADataSource.
DriverClassname is mandatorywhen resType is java.sql.Driver.



 Comments   
Comment by Bill Shannon [ 14/Sep/10 ]

Reassign.

Comment by Jagadish [ 25/Sep/10 ]

"Constraints for this bean violated."
Above message is due to "bean-validation" constraints violation. This will
happen for any validation failure, not just for the reported case.

More samples :
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

asadmin set server.resources.jdbc-connection-pool.DerbyPool.max-pool-size=5
remote failure: Could not change the attributes: Constraints for this bean
violated.
Message = Max-pool-size has to be greater than or equal to steady-pool-size
Constraints for this bean violated. Message = Max-pool-size has to be greater
than or equal to steady-pool-size

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

asadmin set server.resources.jdbc-connection-pool.DerbyPool.max-pool-size=0
remote failure: Could not change the attributes:
org.jvnet.hk2.config.ValidationException: Constraints for this bean violated.
Message = maxPoolSize must be greater than or equal to 1
org.jvnet.hk2.config.ValidationException: Constraints for this bean violated.
Message = maxPoolSize must be greater than or equal to 1

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

asadmin set server.resources.jdbc-connection-pool.DerbyPool.pool-resize-quantity=-1
remote failure: Could not change the attributes:
org.jvnet.hk2.config.ValidationException: Constraints for this bean violated.
Message = poolResizeQuantity must be greater than or equal to 1
org.jvnet.hk2.config.ValidationException: Constraints for this bean violated.
Message = poolResizeQuantity must be greater than or equal to 1

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Either Config or HK2 module need to take care of this.

Comment by Tom Mueller [ 27/Sep/10 ]

The bean validation logic doesn't have any way to translate a validation failure
into a message about command line options. To do this, the command would need to
catch the validation exception, determine what the failure was, and then produce
an appropriate message. However, the trick here is to figure out how to catch the
validation exception and translate it into a command exception with a different
error message. Check with Jerome on that.

Comment by Jagadish [ 27/Sep/10 ]

This issue is not related to individual module or individual command.
This is common for all "configuration" beans that use bean-validation.
Instead of expecting individual modules/commands to handle the message, it would
be helpful if config / hk2 can handle this.

IIUC, the bug submitter's suggestion is :
eg:

Instead of :

remote failure: Could not change the attributes:
org.jvnet.hk2.config.ValidationException: Constraints for this bean violated.
Message = poolResizeQuantity must be greater than or equal to 1

It should be :
poolResizeQuantity must be greater than or equal to 1

Comment by Tom Mueller [ 27/Sep/10 ]

Please reread the description. The submitter doesn't mention anything about
poolSizeQuantity. I agree that the bean validation message should be cleaned up
so that it doesn't have "Message = " or repeat the message; that would be a
different bug.

The submitters request was to change:

"Must specify a datasource/driver classname. DatasourceClassname is mandatory
when resType is
javax.sql.DataSource/javax.sql.ConnectionPoolDataSource/javax.sql.XADataSource.
DriverClassname is mandatory when resType is java.sql.Driver."

to

"Must specify a datasource/driver classname. The option --datasourceclassname or
--driverclassname is mandatory."

This reference to command options is specific to a particular command and cannot
be handled by the configuration framework without having knowledge about how
command options map to bean properties.

Comment by Jagadish [ 27/Sep/10 ]

Thanks, I have raised issue 13625 to track the bean validation related issue.

Comment by Tom Mueller [ 28/Sep/10 ]
      • Issue 13625 has been marked as a duplicate of this issue. ***
Comment by Jagadish [ 05/Oct/10 ]

setting target milestone

Comment by Jagadish [ 30/Oct/10 ]

Here is the latest output.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
asadmin create-jdbc-connection-pool foobar
remote failure: JDBC connection pool foobar creation failed. Constraints for
this bean violated.
Message = Must specify either datasource-classname or driver-classname.
datasource-classname is mandatory when res-type is javax.sql.DataSource or
javax.sql.ConnectionPoolDataSource or javax.sql.XADataSource. driver-classname
is mandatory when res-type is java.sql.Driver.

Command create-jdbc-connection-pool failed.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

There are two parts :
Part 1 :
"remote failure: JDBC connection pool foobar creation failed. Constraints for
this bean violated. "
Part 2 :
Message = Must specify either datasource-classname or driver-classname.
datasource-classname is mandatory when res-type is javax.sql.DataSource or
javax.sql.ConnectionPoolDataSource or javax.sql.XADataSource. driver-classname
is mandatory when res-type is java.sql.Driver.

Part 1 of the message is from the common framework. I have raised issue 13625
for the same.

Part 2 of the message is a bit verbose as it indicates the appropriate parameter
(either datasource-classname or driver-classname) to be used for various
"res-type".
If we provide the message : "either datasource-classname or driver-classname is
mandatory", then the relationship with restype is not clarified here.

Hence, I feel that current message is fine as we are trying to give more
information in the message w.r.t "restype" and "driver/datasource-classname"

Comment by vince kraemer [ 01/Nov/10 ]

The primary problem that I was concerned about is the following...

The error message does not provide feedback to the user in terms of the valid options to the command
that failed..

datasource-classname should be --datasourceclassname
driver-classname should be --driverclassname

in the error message.

Comment by Jagadish [ 02/Nov/10 ]

The difference in names is because they are from the config validation module
(that validates before persisting a configuration in domain.xml) which is common
for both CLI and GUI. Only other option would be to duplicate this validation in
CLI also.

Comment by vince kraemer [ 02/Nov/10 ]

can you have the message that gets generated by the config validation 'filtered' by the cli command to
remap the strings in the error message into the vocabulary of the command that executed?





Generated at Sat Aug 29 08:09:40 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.