Failed authentication due to destroyed database connections
moojid Aug 23, 2005 3:58 PMHello Everyone,
I am using DatabaseServerLoginModule for form based login in my application. The database is MySql Server and the data source config file is setup to create a pool of minimum connection size 2. when I start my server every thing works perfectly. Although when the initial two connections time out the server throws two exceptions (for each connection in the pool) and destroys those two connections. Any subsequent attempts to login simply fail as server does not have any more connections to database.
My question is how can I configure the system to recreate connections when it does not have any more connections left?
I would really appreciate any help
This is what I have right now:
JBoss 4.0.2RC1
JDK 1.5.0_02
MySQL 4.1.11 ?nt
Database and JBoss running on same machine.
Using DatabaseServerLoginModule.
Here is the data-source file:
<?xml version="1.0" encoding="UTF-8" ?> <datasources> <local-tx-datasource> <jndi-name>ComplaintDS</jndi-name> <connection-url>jdbc:mysql:///custcomplaint?autoReconnect=true</connection-url> <driver-class>com.mysql.jdbc.Driver</driver-class> <user-name>complaint</user-name> <password>complaint</password> <min-pool-size>2</min-pool-size> <max-pool-size>20</max-pool-size> <idle-timeout-minutes>0</idle-timeout-minutes> <check-valid-connection-sql>SELECT * from roles</check-valid-connection-sql> <track-statements /> </local-tx-datasource> </datasources>
This is section of web.xml concerned with security:
<security-constraint> <web-resource-collection> <web-resource-name>action</web-resource-name> <url-pattern>/close.do</url-pattern> <url-pattern>/MyHtml.html</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <auth-constraint> <role-name>quality</role-name> </auth-constraint> </security-constraint> <login-config> <auth-method>FORM</auth-method> <form-login-config> <form-login-page>/pages/login.jsp</form-login-page> <form-error-page>/pages/login_error.jsp</form-error-page> </form-login-config> </login-config> <security-role> <role-name>quality</role-name> </security-role>
Here is the jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?> <jboss-web> <security-domain>java:/jaas/complaint</security-domain> </jboss-web> Here is the relevant part of login-config.xml <application-policy name = "complaint"> <authentication> <login-module code="org.jboss.security.ClientLoginModule" flag="required"> </login-module> <login-module code = "org.jboss.security.auth.spi.DatabaseServerLoginModule" flag = "required"> <module-option name = "dsJndiName">java:/ComplaintDS</module-option> <module-option name = "principalsQuery">SELECT Password FROM USERS WHERE LOGIN=?</module-option> <module-option name = "rolesQuery">SELECT ROLE, 'Roles' FROM ROLES WHERE LOGIN=?</module-option> </login-module> </authentication> </application-policy>