Jetty JTA via JNDI with Spring

Finally got Jetty 8 to have JTA transactions available to Spring via JNDI
lookup using Atomikos 3.8 after a lot of trouble. I’m not 100% sure if this is correct but it
seems to be working for me.

My main driver was not wanting to have Atomikos classes hardcoded in the spring config.
Instead we can just register the Atomikos UserTransactionManager and UserTransactionImp
classes in JNDI and have Spring look them up, just like if we were using Websphere, Weblogic,
etc. Now I can use Jetty for local development instead of Websphere without any change to my
actual code base. (Be warned that I’m not using this in prod.)


1) Jetty 8 install

    Download, unzip, setup JETTY_HOME var
for IntelliJ to use

2) Atomikos 3.8 install


    copy from the Atomikos lib/ directory into Jetty




    copy all the JARs from the Atomikos dist/ directory into Jetty

    (Hat tip to this blogpost for

3) Jetty config for JTA (Ref
that helped)

4) Spring JTA lookup

    Spring will lookup using standard JNDI locations of
java:/TransactionManager and java:comp/UserTransaction