I think I've figured out to do this now.
i.e. make jta and jca lazy
The changes are required are roughly:
1) java:/UserTransaction, java:/TransactionSynchronizationRegistry
These need to be replaced by something that bootstraps the UserTransaction (JTA implementation) on demand at first use.
There's an issue with it doing this for the TSR:
2) RAR Bootstrap Context
The use of the XATerminator needs making lazy such that first use of the XATerminator
This needs changing such that the transaction manager is injected using
an incallback with cardinality 0..1
i.e. You can run the CCM without a transaction manager, but it can
cutover to using one if it becomes available later
4) Tomcat valves
These need similar processing to the what is described above for the CCM,
i.e. you can run them without the relevant service, but if something bootstraps it
later they will start doing the extra processing.
5) Testing and reasonable error messages when JCA and JTA is not
My first look at what would happen without JCA and JTA
didn't give the message I expected. I expected to see a problem with
accessing the UserTransaction but instead I got this: