-
1. Re: EJB Transactions over multiple applications in the same JVM
sfcoy Oct 17, 2013 4:49 AM (in response to qtm)This should be the case even if the EARs are deployed on different servers.
-
2. Re: EJB Transactions over multiple applications in the same JVM
qtm Oct 17, 2013 5:40 AM (in response to sfcoy)So, do all the 3 bean share the same persistence context? I've read that beans from other apps should be used as remote and not local beans.
-
3. Re: EJB Transactions over multiple applications in the same JVM
sfcoy Oct 17, 2013 7:57 AM (in response to qtm)1 of 1 people found this helpfulI do not believe so.
I suspect that any JPA entities passed as arguments between applications would need to be transferred between persistence contexts.
ie. detached by the sender and merged by the receiver
That is, unless they are not updated (read only), otherwise you will have concurrency problems.
-
4. Re: EJB Transactions over multiple applications in the same JVM
qtm Oct 17, 2013 9:37 AM (in response to sfcoy)So, if each app has its own persistence context how are the transactions managed? XA? by default - without me configuring anything?
-
5. Re: EJB Transactions over multiple applications in the same JVM
qtm Oct 23, 2013 11:30 AM (in response to qtm)Can someone clear this for me pls?
-
6. Re: EJB Transactions over multiple applications in the same JVM
wdfink Oct 23, 2013 1:48 PM (in response to qtm)If you use the remote interface of the EJB (I suppose you use ejb3) this will handled by the ejb-client library.
The transaction is automaticaly propagated and use an XA approach even if you run the app with two different servers.
The problem is, if you use the same entities in both applications (which should not be very common) you might run into concurrency problems as the entities are loaded by different managers and if you update it in app1, call app2 update it here app1 is not aware about the update and think that the current entity is up-to-date.
If you have such use-case you need to re-read the entity or use a detach/attach as scoy said and ensure that you have an actual entity after returned from the other app.