I have read an interesting article about XA transactions using Spring. This article gives step by step instructions to implement XA transactions using Atomikos's JTA implementation and Bitronix's JTA implementation.
To learn more about XA, Principles of Transaction Processing is a very good book, which covers the 2PC failure conditions and optimizations in great detail. Also, Mike Spille's blog (see Resources section) is another good resource, which focuses on XA within the JTA context and provides wealth of information, especially on failures during 2PC and helps understand more about XA transactions.
Please click XA transactions using Spring to read more about it.