title: Why does an exception in LocalXAResourceImpl.commit() merely give a warning?
body: <p>In WildFly 8, I am using a distributed transaction containing an Oracle XA datasource and a custom JCA LocalTransaction resource (a connection to a file).</p>
  
  <p>Basically it works as expected - if one of the resources fails to commit, the whole transaction is rolled back and neither the database nor the file is updated/written.</p>
  
  <p>There is a special case however. Using JPA, if I am doing an <code>entityManager.merge(entity);</code> and the values of the entity are the same as those in the database, and writing to the file fails (i.e. because it does not exist), all I get is a warning and no exception thrown in my EJB:</p>
  
  <pre><code>@Stateless
  public class JCABean {
  
      @PersistenceContext(unitName = "file-tx") 
      private EntityManager entityManager;
  
      @Resource(name = "java:/FileDataSource")
      private IDataSource fileDataSource;
  
      public void insert(
              final long id, 
              final String value, 
              final boolean update) {
  
          final FileTxTest entity = new FileTxTest();
          entity.setId(id);
          entity.setValue(value);
  
          if (update) {
              entityManager.merge(entity);
          } else {
              entityManager.persist(entity);
          }
  
          final File file = new File(FileHelper.BASE_PATH, 
                  String.format("%s.txt", id));
          try (final IConnection connection = fileDataSource.getConnection(
                  file.getAbsolutePath())) {
              connection.write(String.format("%s%n", value));
          }
      }
  }
  </code></pre>
  
  <p><code>fileDataSource.getConnection()</code> returns an instance of <code>FileConnection</code> implementing <code>LocalTransaction</code>.</p>
  
  <p>If <code>file</code> is not writeable, <code>connection.commit()</code> throws a <code>ResourceException</code>.</p>
  
  <p>If the value given to <code>entity.setValue()</code> equals the value in the database (and <code>update == true</code> so a merge is done), only this warning is issued:</p>
  
  <pre><code>16:33:58,276 WARN  [com.arjuna.ats.jta] (default task-4) ARJUNA016039: onePhaseCommit on &lt; formatId=131077, gtrid_length=29, bqual_length=36, tx_uid=0:ffff7f000101:842ac6d:56699b01:22, node_name=1, branch_uid=0:ffff7f000101:842ac6d:56699b01:2a, subordinatenodename=null, eis_name=java:/FileDataSource &gt; (LocalXAResourceImpl@1e22d60[connectionListener=e1ca39 connectionManager=1b9de9e warned=false currentXid=null productName=Generic JCA productVersion=1.0 jndiName=java:/FileDataSource]) failed with exception XAException.XA_RBROLLBACK: org.jboss.jca.core.spi.transaction.local.LocalXAException: IJ001156: Could not commit local transaction
          at org.jboss.jca.core.tx.jbossts.LocalXAResourceImpl.commit(LocalXAResourceImpl.java:180) [ironjacamar-core-impl-1.1.9.Final.jar:1.1.9.Final]
          at com.arjuna.ats.internal.jta.resources.arjunacore.XAOnePhaseResource.commit(XAOnePhaseResource.java:113)
          at com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord.topLevelPrepare(LastResourceRecord.java:152)
  </code></pre>
  
  <p>If the entity being merged has an updated value, the whole transaction fails as expected:</p>
  
  <pre><code>Caused by: javax.transaction.RollbackException: ARJUNA016053: Could not commit transaction.
      at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1178)
      at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:126)
      at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)
      at org.jboss.as.ejb3.tx.CMTTxInterceptor.endTransaction(CMTTxInterceptor.java:93) [wildfly-ejb3-8.2.1.Final.jar:8.2.1.Final]
  </code></pre>
  
  <p>So effectively, the "all or nothing" requirement is satisfied, but I'd like to have the transaction fail with an exception in any case so I can raise an error.</p>
  
  <p>The Oracle XA datasource:</p>
  
  <pre><code>&lt;xa-datasource jndi-name="java:/OracleDS" pool-name="OracleDS" enabled="true"&gt;
      &lt;xa-datasource-property name="URL"&gt;
          jdbc:oracle:thin:@host.domain.tld:1521:NAME
      &lt;/xa-datasource-property&gt;
      &lt;driver&gt;oracle&lt;/driver&gt;
      &lt;xa-pool&gt;
          &lt;min-pool-size&gt;1&lt;/min-pool-size&gt;
          &lt;max-pool-size&gt;5&lt;/max-pool-size&gt;
          &lt;prefill&gt;true&lt;/prefill&gt;
      &lt;/xa-pool&gt;
      &lt;security&gt;
          &lt;user-name&gt;user&lt;/user-name&gt;
          &lt;password&gt;pass&lt;/password&gt;
      &lt;/security&gt;
  &lt;/xa-datasource&gt;
  &lt;drivers&gt;
      &lt;driver name="oracle" module="com.oracle"&gt;
          &lt;xa-datasource-class&gt;oracle.jdbc.xa.client.OracleXADataSource&lt;/xa-datasource-class&gt;
      &lt;/driver&gt;
  &lt;/drivers&gt;
  </code></pre>
  
  <p>and the resource adapter:</p>
  
  <pre><code>&lt;resource-adapters&gt;
      &lt;resource-adapter id="file-tx-jca.rar"&gt;
          &lt;archive&gt;
              file-tx-jca.rar
          &lt;/archive&gt;
          &lt;transaction-support&gt;LocalTransaction&lt;/transaction-support&gt;
          &lt;config-property name="Server"&gt;
              localhost
          &lt;/config-property&gt;
          &lt;config-property name="Port"&gt;
              19000
          &lt;/config-property&gt;
          &lt;connection-definitions&gt;
              &lt;connection-definition class-name="my.package.GenericManagedConnectionFactory" jndi-name="java:/FileDataSource" pool-name="FileConnectionFactory"&gt;
                  &lt;pool&gt;
                      &lt;min-pool-size&gt;1&lt;/min-pool-size&gt;
                      &lt;max-pool-size&gt;5&lt;/max-pool-size&gt;
                  &lt;/pool&gt;
                  &lt;security&gt;
                      &lt;application/&gt;
                  &lt;/security&gt;
              &lt;/connection-definition&gt;
          &lt;/connection-definitions&gt;
      &lt;/resource-adapter&gt;
  &lt;/resource-adapters&gt;
  </code></pre>
  
  <p>NOTE: I am aware that I can enlist at most one LocalTransaction resource (last resource) in a transaction. Since I might need to handle more than one file in the same transaction, I have changed the <code>FileConnection</code> and the <code>&lt;resource-adapter&gt;</code> to an <code>XAResource</code>/<code>XATransaction</code>. Here, the transaction always fails if a commit fails (i.e. by throwing an <code>XAException(XAException.XA_HEURHAZ)</code>). But I still would like to understand why there is only a warning logged if commit of a local transaction fails.</p>
  
  <p>Is there some property I can set to get an exception even in that case where I currently only get a warning?</p>