It's because Infinispan registers itself with the transaction manager by default as a "synchronization" instead of a full XA resource. Synchronizations are not allowed to throw XAExceptions in their afterCompletion()
methods, and the transaction managers (including DummyTransactionManagerLookup
) swallow any runtime exceptions.
In optimistic mode, the keys and values are replicated during beforeCompletion()
, which is allowed to throw an exception in order to cancel the transaction.
In pessimistic mode, you should configure Infinispan to register as an XA resource instead:
configuration.transaction().useSynchronization(false);
Edit: By default, DummyTransactionManager
doesn't support XA transactions, so you also need to configure it for XA (or even better, use Narayana):
DummyTransactionManager.getInstance().setUseXaXid(true);