简体   繁体   中英

Wildfly Transactions

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:

javax.persistence.PersistenceException:org.hibernate.exception.GenericJDBCException: Could not open connection

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:

@TransactionAttribute(REQUIRES_NEW)

Now the server is running the copy operation without any exception but at the end the log says:

2016-06-30 14:41:06,262 WARN [com.arjuna.ats.jta] (Thread-1195 (HornetQ-client-global-threads-252748997)) ARJUNA016041: prepare on < 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 except ion XAException.XA_RBOTHER: javax.transaction.xa.XAException

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.

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.

The Hibernate exception is occurs at following part

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 + " => " + e);
}

But I think there is some connection/transaction/etc. pool overflowing. However the Wildfly statistics about the connection and transaction seems normal.

Try to add "autoreconnect" to the JNDI datasource you've configured in WildFly. Don't forget to reload the server after doing so.

jdbc:mysql://localhost:3306/database?autoReconnect=true

you have a limited connection number in the datasource pool. With this annotation you will create a new transaction per method call. Check that your datasource is not configured as XA datasource if you don't need multiple resources like JMS and database in the same transaction. If you really needs to use XA transactions maybe you need to reuse connections per transaction. It is a common thing in several jboss's quickstarts to use a shared transaction manager between a JMS queue and a XA datasource.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM