I am trying to persist objects to a Derby database using EclipseLink JPA using the JTA transaction type in a Java Future.
When I am doing this, I am getting the following error:
javax.persistence.TransactionRequiredException:
Exception Description: No externally managed transaction is currently active for this thread
When I try to get a transaction via entityManager.getTransaction(), I get the message that this is not supported for JTA. Also I tried to use an EntityManagerFactory to create an entityManager, as I read that this version is thread safe. However, I then get the error that EntityManagerFactory can also not be used with JTA.
Persisting these objects on the main thread works perfectly. It is really a problem of the multi threading.
I am persisting the object like entityManager.persist(object);
Is there any way of persisting objects into Derby via EclipseLink JTA in another thread than the main thread? (Since this is a general question, I think it is not necessary to add sample code.)
Thanks a lot in advance!