title: How to implement XA connection support in tomcat connection pool using springs?
body: <p>I have to implement jdbc connection pooling that supports XA transaction in my mule flow. Using springs, i have implemented datasource as below</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;mule xmlns:core="http://www.mulesoft.org/schema/mule/core"
      xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
      xmlns:jbossts="http://www.mulesoft.org/schema/mule/jbossts" xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
      xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking"
      xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc" xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
      xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.2"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
  http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd
  http://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-ee.xsd
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
  http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
  http://www.mulesoft.org/schema/mule/jbossts http://www.mulesoft.org/schema/mule/jbossts/current/mule-jbossts.xsd
  http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
  http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd"&gt;
  
      &lt;spring:beans&gt;
          &lt;spring:bean id="MySQL_Pooled_Data_Source" class="org.apache.tomcat.jdbc.pool.XADataSource"
              name="Bean"&gt;
              &lt;spring:property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
              &lt;spring:property name="url"
                  value="jdbc:mysql://10.213.32.13:3306/DB_NE60BMRS_REP" /&gt;
              &lt;spring:property name="username" value="Tester249" /&gt;
              &lt;spring:property name="password" value="Tester249" /&gt;
              &lt;spring:property name="maxActive" value="100" /&gt;
              &lt;spring:property name="minIdle" value="10" /&gt;
              &lt;spring:property name="initialSize" value="5" /&gt;
          &lt;/spring:bean&gt;
      &lt;/spring:beans&gt;
  
      &lt;jdbc-ee:connector name="Reporting_Database"
          dataSource-ref="MySQL_Pooled_Data_Source" validateConnections="true"
          queryTimeout="-1" pollingFrequency="0" doc:name="Database"&gt;
          &lt;reconnect blocking="false" frequency="10000" count="3"&gt;&lt;/reconnect&gt;
      &lt;/jdbc-ee:connector&gt;
      &lt;vm:connector name="VM_Connector" validateConnections="true"
          doc:name="VM_Connector" createMultipleTransactedReceivers="true"
          numberOfConcurrentTransactedReceivers="4"&gt;
      &lt;/vm:connector&gt;
  
      &lt;flow name="ApiKeyLoadImplFlow" doc:name="ApiKeyLoadImplFlow"
          initialState="started"&gt;
  
          &lt;vm:inbound-endpoint exchange-pattern="request-response"
              doc:name="Impl_ApiKeyLoad_Req" path="ImplApiKeyLoadReq"
              connector-ref="VM_Connector" responseTimeout="${vm.response.timeout}"&gt;
              &lt;xa-transaction action="BEGIN_OR_JOIN" /&gt;
          &lt;/vm:inbound-endpoint&gt;
          &lt;logger message="Start of Api Key Load Implementation" level="DEBUG"
              doc:name="ENTRY_LOG" /&gt;
          &lt;set-variable variableName="FlowData" value="#[payload]"
              doc:name="FlowData" /&gt;
          &lt;set-variable variableName="#['UserId']" value="#[payload.getUserID()]"
              doc:name="UserID" /&gt;
  
              &lt;jdbc-ee:outbound-endpoint exchange-pattern="request-response"
              queryKey="checkdata" queryTimeout="-1" connector-ref="Reporting_Database"
              doc:name="Check_Value_Exists"&gt;
              &lt;xa-transaction action="JOIN_IF_POSSIBLE" /&gt;
              &lt;jdbc-ee:query key="checkdata"
                  value="${ftp.db.t_bmrs_api_keys.checkdata.query}" /&gt;
  
          &lt;/jdbc-ee:outbound-endpoint&gt;
  
          &lt;logger message="End of Api Key Load Implementation" level="DEBUG"
              doc:name="EXIT_LOG" /&gt;
  
  
          &lt;catch-exception-strategy doc:name="Catch Exception Strategy"&gt;
              &lt;logger level="WARN" doc:name="Exception_Log"
                  message="Exception in ApiKeyLoadImplFlow #[System.getProperty('line.separator')] Error Description = #[exception.getMessage()]" /&gt;
  
          &lt;/catch-exception-strategy&gt;
      &lt;/flow&gt;
  &lt;/mule&gt;
  </code></pre>
  
  <p>But i am facing below exceptions. how to implement <code>XAconnection</code> support for above pooling using springs?</p>
  
  <pre><code>ERROR 2015-12-17 15:51:37,626 [[apikey_load_phase3].Mule.02] org.mule.retry.notifiers.ConnectNotifier: Failed to connect/reconnect: EEJdbcConnector
  {
    name=Reporting_Database
    lifecycle=initialise
    this=15db0f5
    numberOfConcurrentTransactedReceivers=4
    createMultipleTransactedReceivers=false
    connected=false
    supportedProtocols=[jdbc]
    serviceOverrides=&lt;none&gt;
  }
   *Root Exception was: Connection from pool does not implement javax.sql.XAConnection(SQL Code: 0, SQL State: + null). Type: class java.sql.SQLException*
  </code></pre>