I see one problem in your code: you defined you PersistenceContext as being JTA, but work with the RESOURCE_LOCAL transaction API (i.e EntityManager.getTransaction()
).
As you are in a Java EE environment, just get an injected instance of UserTransaction
: @Resource private UserTransaction transaction;
and of an EntityManager
instead of creating one. Also you should disable the CMT (container managed) transactions, otherwise they are automatically opened/closed.