Greetings,

We are developing some kind of business-processing system based on deductive knowledge base. This knowledge base supports ACID transactions and implemented as transactional resource (XAResource) so it can participate in distributed transactions (tho-phased commits, recovery etc).

Knowledge base has ability to maintain several kinds of integrity contraints on contained entries (uniqueness contraint for example). Ideally, theese contraints must be checked only when transaction is commited, not when every transactional operation is performed. However, there is small difficulty.

According to JTA-specification (X/Open DTP, actually), transactional resource must check all integrity constraints during XAResource.prepare() call. This method can either succeed or throw XAException. In later case, transaction manager throws RollbackException to the application. Even more, this exception is handled by middleware and rethrown as even more meaningless runtime-exception. Neither XAException, nor RollbackException is indented to contain rich error description. Thus, seems that there is no standart (in JTA sense at least) way to report the cause of error during commitment process from transactional resource.

We are considering following workaround: application code during transaction registers in transactional resource special object ErrorListener, which is invoked if error was found while performing XAResource.prepare() before throwing XAException. However this approach has it's drawbacks and obviously far from being ideal.

I tried to google out some pattern or at lease working solution but no luck. Maybe somebody knows how to solve this problem or perhaps developed/encountered another workaround or at least has some random thought on this subject?

Thank you.