Hi Seyvet,
If you look at those two stack traces you can see a common line:
at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.afterCompletion(TwoPhaseCoordinator.java:402)
The only ordering that can be guaranteed is for interposed synchronizations (registered by the TransactionSynchronizationRegistry):
http://docs.oracle.com/javaee/5/api/javax/transaction/TransactionSynchronizationRegistry.html#registerInterposedSynchronization%28javax.transaction.Synchronization%29
There was a little mistype in my original response which I will now refactor in the original to say:
...
foreach ResourceManager
rm::commit()
foreach InterposedSynchronization
s::beforeCompletion();
foreach Synchronization
s::afterCompletion();
i.e. When it comes to afterCompletion, interposed synchronizations will be called *first* which is one way (if you only have two synchronizations ;) ) to guarentee order.