3 Replies Latest reply on Aug 29, 2005 12:57 PM by moojid

    Failed authentication due to destroyed database connections

    moojid

      Hello 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>


        • 1. Re: Failed authentication due to destroyed database connecti
          starksm64

          You need to figure out the connection problem as the point of the pool is to ensure there are not unbounded connections active.

          • 2. Re: Failed authentication due to destroyed database connecti
            moojid

            I think that there are two issues here,

            1- Connection pool is not creating new connections when the connection count goes below minimum. What I can not figure out is why it is able to create connections when the DS is deployed but fails when it needs to replace stale ones.

            2- Second issue is why does DatabaseServerLoginModule silently fails when it is not able to get any connections from the pool, should't it throw some sort of exception?


            Best regards.

            • 3. Re: Failed authentication due to destroyed database connecti
              moojid

              here is the stack trace if that helps:

              09:33:00,750 WARN [LocalManagedConnectionFactory] Destroying connection that is not valid, due to the following exception:
              com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:

              ** BEGIN NESTED EXCEPTION **

              java.net.SocketException
              MESSAGE: Software caused connection abort: recv failed

              STACKTRACE:

              java.net.SocketException: Software caused connection abort: recv failed
              at java.net.SocketInputStream.socketRead0(Native Method)
              at java.net.SocketInputStream.read(SocketInputStream.java:129)
              at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:104)
              at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:144)
              at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:172)
              at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1839)
              at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2288)
              at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2788)
              at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1531)
              at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1622)
              at com.mysql.jdbc.Connection.execSQL(Connection.java:2379)
              at com.mysql.jdbc.Connection.execSQL(Connection.java:2306)
              at com.mysql.jdbc.Statement.execute(Statement.java:911)
              at org.jboss.resource.adapter.jdbc.CheckValidConnectionSQL.isValidConnection(CheckValidConnectionSQL.java:44)
              at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnectionFactory.isValidConnection(BaseWrapperManagedConnectionFactory.java:455)
              at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.checkValid(BaseWrapperManagedConnection.java:263)
              at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.matchManagedConnections(LocalManagedConnectionFactory.java:183)
              at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:166)
              at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:534)
              at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:395)
              at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:299)
              at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:447)
              at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:870)
              at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:102)
              at org.jboss.security.auth.spi.DatabaseServerLoginModule.getUsersPassword(DatabaseServerLoginModule.java:97)
              at org.jboss.security.auth.spi.UsernamePasswordLoginModule.login(UsernamePasswordLoginModule.java:156)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
              at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
              at javax.security.auth.login.LoginContext$4.run(LoginContext.java:683)
              at java.security.AccessController.doPrivileged(Native Method)
              at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
              at javax.security.auth.login.LoginContext.login(LoginContext.java:579)
              at org.jboss.security.plugins.JaasSecurityManager.defaultLogin(JaasSecurityManager.java:483)
              at org.jboss.security.plugins.JaasSecurityManager.authenticate(JaasSecurityManager.java:425)
              at org.jboss.security.plugins.JaasSecurityManager.isValid(JaasSecurityManager.java:251)
              at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.authenticate(JBossSecurityMgrRealm.java:231)
              at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:256)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:391)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:53)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:743)
              at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
              at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
              at java.lang.Thread.run(Thread.java:595)


              ** END NESTED EXCEPTION **


              at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2500)
              at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2788)
              at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1531)
              at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1622)
              at com.mysql.jdbc.Connection.execSQL(Connection.java:2379)
              at com.mysql.jdbc.Connection.execSQL(Connection.java:2306)
              at com.mysql.jdbc.Statement.execute(Statement.java:911)
              at org.jboss.resource.adapter.jdbc.CheckValidConnectionSQL.isValidConnection(CheckValidConnectionSQL.java:44)
              at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnectionFactory.isValidConnection(BaseWrapperManagedConnectionFactory.java:455)
              at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.checkValid(BaseWrapperManagedConnection.java:263)
              at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.matchManagedConnections(LocalManagedConnectionFactory.java:183)
              at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:166)
              at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:534)
              at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:395)
              at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:299)
              at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:447)
              at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:870)
              at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:102)
              at org.jboss.security.auth.spi.DatabaseServerLoginModule.getUsersPassword(DatabaseServerLoginModule.java:97)
              at org.jboss.security.auth.spi.UsernamePasswordLoginModule.login(UsernamePasswordLoginModule.java:156)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
              at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
              at javax.security.auth.login.LoginContext$4.run(LoginContext.java:683)
              at java.security.AccessController.doPrivileged(Native Method)
              at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
              at javax.security.auth.login.LoginContext.login(LoginContext.java:579)
              at org.jboss.security.plugins.JaasSecurityManager.defaultLogin(JaasSecurityManager.java:483)
              at org.jboss.security.plugins.JaasSecurityManager.authenticate(JaasSecurityManager.java:425)
              at org.jboss.security.plugins.JaasSecurityManager.isValid(JaasSecurityManager.java:251)
              at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.authenticate(JBossSecurityMgrRealm.java:231)
              at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:256)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:391)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:53)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:743)
              at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
              at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
              at java.lang.Thread.run(Thread.java:595)
              09:33:00,875 WARN [JBossManagedConnectionPool] Destroying connection that could not be successfully matched: org.jboss.resource.connectionmanager.TxC
              onnectionManager$TxConnectionEventListener@633b88[state=DESTROYED mc=org.jboss.resource.adapter.jdbc.local.LocalManagedConnection@b612f8 handles=0 las
              tUse=1125007346375 permit=false trackByTx=false mcp=org.jboss.resource.connectionmanager.JBossManagedConnectionPool$OnePool@93b59 context=org.jboss.re
              source.connectionmanager.InternalManagedConnectionPool@1975d46]