<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    MySQL XA Datasource - "No matching credentials in Subject!"
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/ymaraner">Tim Haley</a> in <i>Datasource Configuration</i> - <a href="http://community.jboss.org/message/619728#619728">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>I am working with JBoss AS 6.0.0.Final and 6.1.0-SNAPSHOT-68, they both have the same issue:</p><p>I have a MySQL database running on the localhost at port 56838</p><p>I configured an xa-datasource.</p><p>When I test the datasource via the Admin Console, or when my application attemts to access the datasources, I get the following error:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-noformat-content">
 13:54:53,996 WARN&#160; [org.jboss.resource.connectionmanager.JBossManagedConnectionPool] Throwable while attempting to get a new connection: null: org.jboss.resource.JBossResourceException: No matching credentials in Subject!
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnectionFactory.getConnectionProperties(BaseWrapperManagedConnectionFactory.java:506) [:6.0.0-Final]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:191) [:6.0.0-Final]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:648) [:6.0.0-Final]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:272) [:6.0.0-Final]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:690) [:6.0.0-Final]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:403) [:6.0.0-Final]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:380) [:6.0.0-Final]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:496) [:6.0.0-Final]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:941) [:6.0.0-Final]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89) [:6.0.0-Final]

</pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The Admin Console reports that a connection was obtained, but the exception above appears in the console output. My application is not expecting this exception, so it fails when it receives this exception.</p><p>My configuration is as follows:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>MySQL-ds.xml: </p><pre class="jive-pre"><code class="jive-code jive-xml">

<span class="jive-xml-tag">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span>
&lt;!DOCTYPE datasources
&#160;&#160;&#160; PUBLIC <span class="jive-xml-quote">-//JBoss//DTD JBOSS JCA Config 6.0//EN</span>
&#160;&#160;&#160; <span class="jive-xml-quote"><a class="jive-link-external-small" href="http://www.jboss.org/j2ee/dtd/jboss-ds_6_0.dtd" target="_blank">http://www.jboss.org/j2ee/dtd/jboss-ds_6_0.dtd</a></span>&gt;&#160;&#160;&#160; 
<span class="jive-xml-tag">&lt;datasources&gt;</span>
&#160;&#160;&#160; <span class="jive-xml-tag">&lt;xa-datasource&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;jndi-name&gt;</span>test/jdbc/XADataSource<span class="jive-xml-tag">&lt;/jndi-name&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;use-java-context&gt;</span>false<span class="jive-xml-tag">&lt;/use-java-context&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;track-connection-by-tx/&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;xa-datasource-class&gt;</span>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource<span class="jive-xml-tag">&lt;/xa-datasource-class&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;xa-datasource-property name="URL"&gt;</span>jdbc:mysql://localhost:56838/testjboss<span class="jive-xml-tag">&lt;/xa-datasource-property&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;isSameRM-override-value&gt;</span>false<span class="jive-xml-tag">&lt;/isSameRM-override-value&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;transaction-isolation&gt;</span>TRANSACTION_READ_COMMITTED<span class="jive-xml-tag">&lt;/transaction-isolation&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;user-name&gt;</span>test<span class="jive-xml-tag">&lt;/user-name&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;password&gt;</span>test<span class="jive-xml-tag">&lt;/password&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;security-domain&gt;</span>XaTxDb<span class="jive-xml-tag">&lt;/security-domain&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;min-pool-size&gt;</span>1<span class="jive-xml-tag">&lt;/min-pool-size&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;max-pool-size&gt;</span>120<span class="jive-xml-tag">&lt;/max-pool-size&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;blocking-timeout-millis&gt;</span>30000<span class="jive-xml-tag">&lt;/blocking-timeout-millis&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;background-validation&gt;</span>false<span class="jive-xml-tag">&lt;/background-validation&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;background-validation-millis&gt;</span>0<span class="jive-xml-tag">&lt;/background-validation-millis&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;idle-timeout-minutes&gt;</span>30<span class="jive-xml-tag">&lt;/idle-timeout-minutes&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;allocation-retry&gt;</span>0<span class="jive-xml-tag">&lt;/allocation-retry&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;allocation-retry-wait-millis&gt;</span>5000<span class="jive-xml-tag">&lt;/allocation-retry-wait-millis&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;validate-on-match&gt;</span>true<span class="jive-xml-tag">&lt;/validate-on-match&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;no-tx-separate-pools/&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;xa-resource-timeout&gt;</span>0<span class="jive-xml-tag">&lt;/xa-resource-timeout&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;track-statements/&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;prefill&gt;</span>false<span class="jive-xml-tag">&lt;/prefill&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;type-mapping&gt;</span>MySQL<span class="jive-xml-tag">&lt;/type-mapping&gt;</span>
&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/xa-datasource&gt;</span>&#160; 
<span class="jive-xml-tag">&lt;/datasources&gt;</span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>My login-config.xml file contains the following application-policy:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-xml"> <span class="jive-xml-tag">&lt;application-policy name = "XaTxDb"&gt;</span>
&#160;&#160; <span class="jive-xml-tag">&lt;authentication&gt;</span>
&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;login-module code="org.jboss.resource.security.ConfiguredIdentityLoginModule"
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; flag="required"&gt;</span>
 <span class="jive-xml-tag">&lt;module-option name="principal"&gt;</span>test<span class="jive-xml-tag">&lt;/module-option&gt;</span>
 <span class="jive-xml-tag">&lt;module-option name="userName"&gt;</span>test<span class="jive-xml-tag">&lt;/module-option&gt;</span>
 <span class="jive-xml-tag">&lt;module-option name="password"&gt;</span>test<span class="jive-xml-tag">&lt;/module-option&gt;</span>
 <span class="jive-xml-tag">&lt;module-option name="managedConnectionFactoryName"&gt;</span>jboss.jca:service=XATxCM,name=test/jdbc/XADataSource<span class="jive-xml-tag">&lt;/module-option&gt;</span>
&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/login-module&gt;</span>
&#160;&#160; <span class="jive-xml-tag">&lt;/authentication&gt;</span>
 <span class="jive-xml-tag">&lt;/application-policy&gt;</span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>If I remove the user-name and password tags from the datasource, I get the same exception but I also get an error message from mysql:<br/>&#160;&#160;&#160; Access denied for user <a class="" href="http://community.jboss.org/mailto:''@'localhost'">''@'localhost'</a> to database 'testjboss'</p><p><br/>If restore the credentials in the datasource and remove the security-domain tag from the datasource and remove the corresponding application policy from login-config.xml, I get the same exception and the admin console reports that a connection was not obtained, but I don't get the mysql exception.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I can get a no-transaction datasource to work, but only if I have both credentials in the datasource and a valid security-domain.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Isn't the security-domain supposed to replace the credentials in the datasource? <br/>If I have credentials in the datasource I shouldn't need a security domain, should I?<br/>And what does "No matching credentials in Subject!" mean?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I have been going around in circles for a couple of days now and any help would be greatly appreciated.</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/619728#619728">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in Datasource Configuration at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2077">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>