4 Replies Latest reply on Aug 25, 2009 9:06 AM by Purushotham Reddy

    No matching credentials in Subject Exception!

    kks_krishna Newbie

      HI,

      I am trying to encrypt the database password and us that in DataSource. For that I have modified login-config.xml(LoginModule) and mysql-ds.xml for configuring datasource. It is accessed through hibernate session. I am getting the following exception. Please help me:


      [org.jboss.resource.connectionmanager.JBossManagedConnectionPool] Throwable while attempting to get a new connection: null
      org.jboss.resource.JBossResourceException: No matching credentials in Subject!
      at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnectionFactory.getConnectionProperties(BaseWrapperManagedConnectionFactory.java:381)
      at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:147)
      at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:577)
      at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:262)
      at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:500)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:341)
      at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:315)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:396)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:842)


        • 1. Re: No matching credentials in Subject Exception!
          Peter Johnson Master

          There is no way we can help you if you do not post the configuration changes you made. And any related code.

          • 2. Re: No matching credentials in Subject Exception!
            kks_krishna Newbie

            The following are the changes I have made. Please help me at the earliest.

            Chamges on Hibernate Configuration file

            <hibernate-configuration>
             <session-factory>
             <property name="dialect">
             org.hibernate.dialect.MySQLDialect
             </property>
             <property name="connection.datasource">java:MySqlDS1</property>
             <mapping
             resource="Offlinetelephone.hbm.xml" />
            
            
            </hibernate-configuration>


            Changes in mysql-ds.xml

            <datasources>
             <local-tx-datasource>
             <jndi-name>MySqlDS</jndi-name>
             <connection-url>jdbc:mysql://192.168.48.227:3306/systemdatabase</connection-url>
             <driver-class>com.mysql.jdbc.Driver</driver-class>
             <min-pool-size>1</min-pool-size>
             <max-pool-size>20</max-pool-size>
             <security-domain>EncryptDBPassword</security-domain>
             <metadata>
             <type-mapping>mySQL</type-mapping>
             </metadata>
             </local-tx-datasource>
             <local-tx-datasource>
             <jndi-name>MySqlDS1</jndi-name>
             <connection-url>jdbc:mysql://192.168.48.227:3306/telephone_element1</connection-url>
             <driver-class>com.mysql.jdbc.Driver</driver-class>
             <min-pool-size>1</min-pool-size>
             <max-pool-size>20</max-pool-size>
             <security-domain>EncryptDBPassword</security-domain>
             <metadata>
             <type-mapping>mySQL</type-mapping>
             </metadata>
             </local-tx-datasource>
            
            </datasources>


            Changes in login-config.xml
            <application-policy name="EncryptDBPassword">
             <authentication>
             <login-module code="org.jboss.resource.security.SecureIdentityLoginModule" flag="required">
            
             <module-option name="username">root</module-option>
             <module-option name="password">6f8e652f571678f2</module-option>
             <module-option name="managedConnectionFactoryName">jboss.jca:name=MySqlDS,service=LocalTxCM</module-option>
             </login-module>
             </authentication>
             </application-policy>


            • 3. Re: No matching credentials in Subject Exception!
              jaikiran pai Master

               

              <module-option name="managedConnectionFactoryName">jboss.jca:name=MySqlDS,service=LocalTxCM</module-option>


              Shouldn't this be:

              <module-option name="managedConnectionFactoryName">jboss.jca:name=MySqlDS1,service=LocalTxCM</module-option>


              • 4. Re: No matching credentials in Subject Exception!
                Purushotham Reddy Newbie

                For your data source you need two <application-policy> tags.

                One is for MySqlDS another is for MySqlDS1.

                You cannot put them into one single
                <application-policy name="EncryptDBPassword">.

                Try the following:

                Your mysql-ds.xml file will be changed like this.

                <datasources>
                 <local-tx-datasource>
                 <jndi-name>MySqlDS</jndi-name>
                 <connection-url>jdbc:mysql://192.168.48.227:3306/systemdatabase</connection-url>
                 <driver-class>com.mysql.jdbc.Driver</driver-class>
                 <min-pool-size>1</min-pool-size>
                 <max-pool-size>20</max-pool-size>
                 <security-domain>EncryptDBPassword</security-domain>
                 <metadata>
                 <type-mapping>mySQL</type-mapping>
                 </metadata>
                 </local-tx-datasource>
                 <local-tx-datasource>
                 <jndi-name>MySqlDS1</jndi-name>
                 <connection-url>jdbc:mysql://192.168.48.227:3306/telephone_element1</connection-url>
                 <driver-class>com.mysql.jdbc.Driver</driver-class>
                 <min-pool-size>1</min-pool-size>
                 <max-pool-size>20</max-pool-size>
                <security-domain>EncryptDBPassword1</security-domain>
                 <metadata>
                 <type-mapping>mySQL</type-mapping>
                 </metadata>
                 </local-tx-datasource>
                </datasources>


                You can observe the brown color change in your mysql-ds.xml.

                Then the login-config.xml file should be like this


                <application-policy name="EncryptDBPassword">
                 <authentication>
                 <login-module code="org.jboss.resource.security.SecureIdentityLoginModule" flag="required">
                
                 <module-option name="username">root</module-option>
                 <module-option name="password">6f8e652f571678f2</module-option>
                 <module-option name="managedConnectionFactoryName">jboss.jca:name=MySqlDS,service=LocalTxCM</module-option>
                 </login-module>
                 </authentication>
                 </application-policy>
                <application-policy name="EncryptDBPassword1">
                 <authentication>
                 <login-module code="org.jboss.resource.security.SecureIdentityLoginModule" flag="required">
                
                 <module-option name="username">root</module-option>
                 <module-option name="password">6f8e652f571678f2</module-option>
                 <module-option name="managedConnectionFactoryName">
                 jboss.jca:name=MySqlDS1, service=LocalTxCM
                 </module-option>
                 </login-module>
                 </authentication>
                </application-policy>



                The main reason for this exception is the application is not getting the MySqlDS1 connection from the connection pool. Because you have not configured MySqlDS1 in the SecureIdentityLoginModule.

                Thanks
                Purushotham