title: Wildfly Transactions
body: <p>My Wildfly server is running a copy method which takes 30 minutes to finish. For every copied item i got a log message. Ater 10 minutes the server is printing following message for around 20 seconds:</p>
  
  <blockquote>
    <p>javax.persistence.PersistenceException:org.hibernate.exception.GenericJDBCException:
    Could not open connection</p>
  </blockquote>
  
  <p>After this the server is continuing with the copy operation. However, when the server is finished all transactions are rolledback. 
  So I tried to add this annotation for my copy method: </p>
  
  <pre><code>@TransactionAttribute(REQUIRES_NEW)
  </code></pre>
  
  <p>Now the server is running the copy operation without any exception but at the end the log says: </p>
  
  <blockquote>
    <p>2016-06-30 14:41:06,262 WARN  [com.arjuna.ats.jta] (Thread-1195
    (HornetQ-client-global-threads-252748997)) ARJUNA016041: prepare on &lt;
    formatId=131077, gtrid_length=29, bqual_length=36,
    tx_uid=0:ffff7f000101:-76961d26:577503fd:1297, node_name=1,
    branch_uid=0:ffff7f000101:-76961d26:577503fd:1298,
    subordinatenodename=null, eis_name=unknown eis name >
    (DelegatingSession [session=ClientSessionImpl
    [name=c2eb2924-3eb6-11e6-8fd4-954338fa95f0, username=null,
    closed=false, factory = ClientSessionFactoryImpl
    [serverLocator=ServerLocatorImpl
    [initialConnectors=[TransportConfiguration(name=bdde9687-3eb6-11e6-8fd4-954338fa95f0,
    factory=org-hornetq-core-remoting-impl-invm-InVMConnectorFactory)
    ?server-id=0], discoveryGroupConfiguration=null],
    connectorConfig=TransportConfiguration(name=bdde9687-3eb6-11e6-8fd4-954338fa95f0,
    factory=org-hornetq-core-remoting-impl-invm-InVMConnectorFactory)
    ?server-id=0, backupConfig=null],
    metaData=(jms-session=,resource-adapter=inbound,)]@62eae143]) failed
    with exception XAException.XA_RBOTHER: javax.transaction.xa.XAException</p>
  </blockquote>
  
  <p>And again  all transactions are rolledback.
  The Wildfly Admin Console Statistics seems normal. When I try to copy less items the operation is running successful without any problems.
  I also tried to increase the transaction-default-timeout value but with the same result.</p>
  
  <p>Update:
  I have a MySQL Database and I want to copy one bean into the same table with some other values. The code is around 1000 lines.</p>
  
  <p>The Hibernate  exception is occurs at following part</p>
  
  <pre><code>try {
      Query query = em.createQuery("SELECT g FROM PCTree g WHERE.parentKey = :parentKey ORDER BY g.orderNumber");
      query.setParameter("parentKey", parentKey);
      List res = query.getResultList();
      return res;
  } catch (Exception e) {
      throw new FinderException("find PCTree.findByParentKey: " + parentKey + " =&gt; " + e);
  }
  </code></pre>
  
  <p>But I think there is some connection/transaction/etc. pool overflowing. However the Wildfly statistics about the connection and transaction seems normal.</p>