<!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;"> </p><pre class="jive-noformat-content">
13:54:53,996 WARN  [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:506) [:6.0.0-Final]
        at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:191) [:6.0.0-Final]
        at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:648) [:6.0.0-Final]
        at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:272) [:6.0.0-Final]
        at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:690) [:6.0.0-Final]
        at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:403) [:6.0.0-Final]
        at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:380) [:6.0.0-Final]
        at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:496) [:6.0.0-Final]
        at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:941) [:6.0.0-Final]
        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;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </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;"> </p><p>MySQL-ds.xml: </p><pre class="jive-pre"><code class="jive-code jive-xml">
<span class="jive-xml-tag"><?xml version="1.0" encoding="UTF-8"?></span>
<!DOCTYPE datasources
    PUBLIC <span class="jive-xml-quote">-//JBoss//DTD JBOSS JCA Config 6.0//EN</span>
    <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>>   
<span class="jive-xml-tag"><datasources></span>
    <span class="jive-xml-tag"><xa-datasource></span>
        <span class="jive-xml-tag"><jndi-name></span>test/jdbc/XADataSource<span class="jive-xml-tag"></jndi-name></span>
        <span class="jive-xml-tag"><use-java-context></span>false<span class="jive-xml-tag"></use-java-context></span>
        <span class="jive-xml-tag"><track-connection-by-tx/></span>
        <span class="jive-xml-tag"><xa-datasource-class></span>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource<span class="jive-xml-tag"></xa-datasource-class></span>
        <span class="jive-xml-tag"><xa-datasource-property name="URL"></span>jdbc:mysql://localhost:56838/testjboss<span class="jive-xml-tag"></xa-datasource-property></span>
        <span class="jive-xml-tag"><isSameRM-override-value></span>false<span class="jive-xml-tag"></isSameRM-override-value></span>
        <span class="jive-xml-tag"><transaction-isolation></span>TRANSACTION_READ_COMMITTED<span class="jive-xml-tag"></transaction-isolation></span>
        <span class="jive-xml-tag"><user-name></span>test<span class="jive-xml-tag"></user-name></span>
        <span class="jive-xml-tag"><password></span>test<span class="jive-xml-tag"></password></span>
        <span class="jive-xml-tag"><security-domain></span>XaTxDb<span class="jive-xml-tag"></security-domain></span>
        <span class="jive-xml-tag"><min-pool-size></span>1<span class="jive-xml-tag"></min-pool-size></span>
        <span class="jive-xml-tag"><max-pool-size></span>120<span class="jive-xml-tag"></max-pool-size></span>
        <span class="jive-xml-tag"><blocking-timeout-millis></span>30000<span class="jive-xml-tag"></blocking-timeout-millis></span>
        <span class="jive-xml-tag"><background-validation></span>false<span class="jive-xml-tag"></background-validation></span>
        <span class="jive-xml-tag"><background-validation-millis></span>0<span class="jive-xml-tag"></background-validation-millis></span>
        <span class="jive-xml-tag"><idle-timeout-minutes></span>30<span class="jive-xml-tag"></idle-timeout-minutes></span>
        <span class="jive-xml-tag"><allocation-retry></span>0<span class="jive-xml-tag"></allocation-retry></span>
        <span class="jive-xml-tag"><allocation-retry-wait-millis></span>5000<span class="jive-xml-tag"></allocation-retry-wait-millis></span>
        <span class="jive-xml-tag"><validate-on-match></span>true<span class="jive-xml-tag"></validate-on-match></span>
        <span class="jive-xml-tag"><no-tx-separate-pools/></span>
        <span class="jive-xml-tag"><xa-resource-timeout></span>0<span class="jive-xml-tag"></xa-resource-timeout></span>
        <span class="jive-xml-tag"><track-statements/></span>
        <span class="jive-xml-tag"><prefill></span>false<span class="jive-xml-tag"></prefill></span>
        <span class="jive-xml-tag"><type-mapping></span>MySQL<span class="jive-xml-tag"></type-mapping></span>
    <span class="jive-xml-tag"></xa-datasource></span> 
<span class="jive-xml-tag"></datasources></span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>My login-config.xml file contains the following application-policy:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code jive-xml"> <span class="jive-xml-tag"><application-policy name = "XaTxDb"></span>
   <span class="jive-xml-tag"><authentication></span>
     <span class="jive-xml-tag"><login-module code="org.jboss.resource.security.ConfiguredIdentityLoginModule"
                   flag="required"></span>
<span class="jive-xml-tag"><module-option name="principal"></span>test<span class="jive-xml-tag"></module-option></span>
<span class="jive-xml-tag"><module-option name="userName"></span>test<span class="jive-xml-tag"></module-option></span>
<span class="jive-xml-tag"><module-option name="password"></span>test<span class="jive-xml-tag"></module-option></span>
<span class="jive-xml-tag"><module-option name="managedConnectionFactoryName"></span>jboss.jca:service=XATxCM,name=test/jdbc/XADataSource<span class="jive-xml-tag"></module-option></span>
     <span class="jive-xml-tag"></login-module></span>
   <span class="jive-xml-tag"></authentication></span>
<span class="jive-xml-tag"></application-policy></span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </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/>    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;"> </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;"> </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;"> </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>