Hi Scott!
I extended my little test application and did some more tests.
My EAR now contains 6 beans:
- TestSLSB1 - stateless session bean with transactional persistence context "xpctestPU"
- TestSLSB2 - stateless session bean with transactional persistence context "xpctestPU"
- TestTPCSFSB1 - stateful session bean with transactional persistence context "xpctestPU"
- TestTPCSFSB2 - stateful session bean with transactional persistence context "xpctestPU"
- TestXPCSFSB1 - stateful session bean with extended persistence context "xpctestPU"
- TestXPCSFSB2 - stateful session bean with extended persistence context "xpctestPU"
All beans derive from the same class AbstractBean which provides one bean method: helloWorld()
This method returns a string with information about the bean, EntityManager, transaction and Hibernate session.
The remote client gets two instances of each bean, calls the helloWorld() method of each one and prints the results to stdout.
It does this twice: First without user transaction (so each method call gets it's own transaction), then inside a single user transaction.
Here are the results with JBAS5:
First the test without user transaction:
Hello testSLSB1a, this is xpctest.TestSLSB1@4e03884e (em=org.jboss.jpa.tx.TransactionScopedEntityManager@4f0ecbfe, identityHashCode=1326369790, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 7f000002:9951:5284db71:63 status: ActionStatus.RUNNING >, session=#174171140)
Hello testSLSB1b, this is xpctest.TestSLSB1@1c4c7ecb (em=org.jboss.jpa.tx.TransactionScopedEntityManager@4f0ecbfe, identityHashCode=1326369790, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 7f000002:9951:5284db71:67 status: ActionStatus.RUNNING >, session=#572823097)
Hello testSLSB2a, this is xpctest.TestSLSB2@5e4e6d6b (em=org.jboss.jpa.tx.TransactionScopedEntityManager@3fce25b5, identityHashCode=1070474677, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 7f000002:9951:5284db71:6b status: ActionStatus.RUNNING >, session=#1810294015)
Hello testSLSB2b, this is xpctest.TestSLSB2@32a00e57 (em=org.jboss.jpa.tx.TransactionScopedEntityManager@3fce25b5, identityHashCode=1070474677, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 7f000002:9951:5284db71:6f status: ActionStatus.RUNNING >, session=#1393888979)
Hello testTPCSFSB1a, this is xpctest.TestTPCSFSB1@54739f65 (em=org.jboss.jpa.tx.TransactionScopedEntityManager@453e5e9b, identityHashCode=1161715355, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 7f000002:9951:5284db71:73 status: ActionStatus.RUNNING >, session=#1426041570)
Hello testTPCSFSB1b, this is xpctest.TestTPCSFSB1@460f34c0 (em=org.jboss.jpa.tx.TransactionScopedEntityManager@453e5e9b, identityHashCode=1161715355, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 7f000002:9951:5284db71:77 status: ActionStatus.RUNNING >, session=#2078163238)
Hello testTPCSFSB2a, this is xpctest.TestTPCSFSB2@3ee430af (em=org.jboss.jpa.tx.TransactionScopedEntityManager@699bf2f1, identityHashCode=1771827953, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 7f000002:9951:5284db71:7b status: ActionStatus.RUNNING >, session=#1071210526)
Hello testTPCSFSB2b, this is xpctest.TestTPCSFSB2@32080ca4 (em=org.jboss.jpa.tx.TransactionScopedEntityManager@699bf2f1, identityHashCode=1771827953, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 7f000002:9951:5284db71:7f status: ActionStatus.RUNNING >, session=#1979514480)
Hello testXPCSFSB1a, this is xpctest.TestXPCSFSB1@68b1caa8 (em=org.jboss.ejb3.entity.ExtendedEntityManager@7e100578, identityHashCode=2114979192, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 7f000002:9951:5284db71:83 status: ActionStatus.RUNNING >, session=#344720025)
Hello testXPCSFSB1b, this is xpctest.TestXPCSFSB1@532902ea (em=org.jboss.ejb3.entity.ExtendedEntityManager@7e100578, identityHashCode=2114979192, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 7f000002:9951:5284db71:86 status: ActionStatus.RUNNING >, session=#107421904)
Hello testXPCSFSB2a, this is xpctest.TestXPCSFSB2@4d88a2cb (em=org.jboss.ejb3.entity.ExtendedEntityManager@4eff235d, identityHashCode=1325343581, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 7f000002:9951:5284db71:89 status: ActionStatus.RUNNING >, session=#905946208)
Hello testXPCSFSB2b, this is xpctest.TestXPCSFSB2@53a268de (em=org.jboss.ejb3.entity.ExtendedEntityManager@4eff235d, identityHashCode=1325343581, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 7f000002:9951:5284db71:8c status: ActionStatus.RUNNING >, session=#1318932559)
As you can see, all tests run fine.
There are some things worth to mention, though:
- Without user transaction each method call gets it's own transaction as you can see from the transaction hash code. No surprise here.
- The bean instances are different for each call (even for SLSB), but the EntityManager instance is the same for both instances of the same bean class each. I didn't expect this.
- Without user transaction, the underlying Hibernate Session is different for each method call (even if the EntityManager is the same). This should answer your last question and this is as expected (IMHO).
Now the tests with user transaction started on the remote client:
Hello testSLSB1a, this is xpctest.TestSLSB1@4e03884e (em=org.jboss.jpa.tx.TransactionScopedEntityManager@4f0ecbfe, identityHashCode=1326369790, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 7f000002:9951:5284db71:8f status: ActionStatus.RUNNING >, session=#1157344337)
Hello testSLSB1b, this is xpctest.TestSLSB1@1c4c7ecb (em=org.jboss.jpa.tx.TransactionScopedEntityManager@4f0ecbfe, identityHashCode=1326369790, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 7f000002:9951:5284db71:8f status: ActionStatus.RUNNING >, session=#1157344337)
Hello testSLSB2a, this is xpctest.TestSLSB2@5e4e6d6b (em=org.jboss.jpa.tx.TransactionScopedEntityManager@3fce25b5, identityHashCode=1070474677, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 7f000002:9951:5284db71:8f status: ActionStatus.RUNNING >, session=#1157344337)
Hello testSLSB2b, this is xpctest.TestSLSB2@32a00e57 (em=org.jboss.jpa.tx.TransactionScopedEntityManager@3fce25b5, identityHashCode=1070474677, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 7f000002:9951:5284db71:8f status: ActionStatus.RUNNING >, session=#1157344337)
Hello testTPCSFSB1a, this is xpctest.TestTPCSFSB1@54739f65 (em=org.jboss.jpa.tx.TransactionScopedEntityManager@453e5e9b, identityHashCode=1161715355, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 7f000002:9951:5284db71:8f status: ActionStatus.RUNNING >, session=#1157344337)
Hello testTPCSFSB1b, this is xpctest.TestTPCSFSB1@460f34c0 (em=org.jboss.jpa.tx.TransactionScopedEntityManager@453e5e9b, identityHashCode=1161715355, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 7f000002:9951:5284db71:8f status: ActionStatus.RUNNING >, session=#1157344337)
Hello testTPCSFSB2a, this is xpctest.TestTPCSFSB2@3ee430af (em=org.jboss.jpa.tx.TransactionScopedEntityManager@699bf2f1, identityHashCode=1771827953, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 7f000002:9951:5284db71:8f status: ActionStatus.RUNNING >, session=#1157344337)
Hello testTPCSFSB2b, this is xpctest.TestTPCSFSB2@32080ca4 (em=org.jboss.jpa.tx.TransactionScopedEntityManager@699bf2f1, identityHashCode=1771827953, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 7f000002:9951:5284db71:8f status: ActionStatus.RUNNING >, session=#1157344337)
Hello testXPCSFSB1a, this is xpctest.TestXPCSFSB1@68b1caa8 (em=org.jboss.ejb3.entity.ExtendedEntityManager@7e100578, identityHashCode=2114979192, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 7f000002:9951:5284db71:8f status: ActionStatus.RUNNING >, session=#344720025)
Hello testXPCSFSB1b, this is xpctest.TestXPCSFSB1@532902ea (em=org.jboss.ejb3.entity.ExtendedEntityManager@7e100578, identityHashCode=2114979192, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 7f000002:9951:5284db71:8f status: ActionStatus.RUNNING >, session=#107421904)
Hello testXPCSFSB2a, this is xpctest.TestXPCSFSB2@4d88a2cb (em=org.jboss.ejb3.entity.ExtendedEntityManager@4eff235d, identityHashCode=1325343581, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 7f000002:9951:5284db71:8f status: ActionStatus.RUNNING >, session=#905946208)
Hello testXPCSFSB2b, this is xpctest.TestXPCSFSB2@53a268de (em=org.jboss.ejb3.entity.ExtendedEntityManager@4eff235d, identityHashCode=1325343581, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 7f000002:9951:5284db71:8f status: ActionStatus.RUNNING >, session=#1318932559)
Again, there are some interesting things worth to mention:
- With user transaction, the transaction is the same for all method calls. This is as expected.
- With user transaction, the underlying Hibernate Session is the same for all SLSB and transaction-scoped PC SFSB. This is a surprise for me, I didn't expect this.
- With user transaction, the underlying Hibernate Session is different for all SFSB with extended PC. This is as expected (IMHO).
With WildFly 8.0.0.Beta2-SNAPSHOT I changed the client a little to test several situations when running inside a user transaction:
- Situation #1: call to beans with transaction-scoped PC, then call bean with XPC
- Situation #2: call to XPC bean, then call another instance of the same XPC bean
- Situation #3: call to XPC bean, then call instance of another XPC bean
Here are the results:
First the test without user transaction:
Hello testSLSB1a, this is xpctest.TestSLSB1@554f842c (em=org.jboss.as.jpa.container.TransactionScopedEntityManager@576e9075, identityHashCode=1466863733, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 0:ffff7f000002:-105ad7d6:5284dcfe:14 status: ActionStatus.RUNNING >, session=#991847412)
Hello testSLSB1b, this is xpctest.TestSLSB1@554f842c (em=org.jboss.as.jpa.container.TransactionScopedEntityManager@576e9075, identityHashCode=1466863733, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 0:ffff7f000002:-105ad7d6:5284dcfe:18 status: ActionStatus.RUNNING >, session=#200800321)
Hello testSLSB2a, this is xpctest.TestSLSB2@21cf0884 (em=org.jboss.as.jpa.container.TransactionScopedEntityManager@1f382373, identityHashCode=523772787, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 0:ffff7f000002:-105ad7d6:5284dcfe:1b status: ActionStatus.RUNNING >, session=#513762056)
Hello testSLSB2b, this is xpctest.TestSLSB2@21cf0884 (em=org.jboss.as.jpa.container.TransactionScopedEntityManager@1f382373, identityHashCode=523772787, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 0:ffff7f000002:-105ad7d6:5284dcfe:1f status: ActionStatus.RUNNING >, session=#1469148164)
Hello testTPCSFSB1a, this is xpctest.TestTPCSFSB1@50f1e31f (em=org.jboss.as.jpa.container.TransactionScopedEntityManager@387631bd, identityHashCode=947270077, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 0:ffff7f000002:-105ad7d6:5284dcfe:22 status: ActionStatus.RUNNING >, session=#1471908928)
Hello testTPCSFSB1b, this is xpctest.TestTPCSFSB1@643f700b (em=org.jboss.as.jpa.container.TransactionScopedEntityManager@d51598, identityHashCode=13964696, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 0:ffff7f000002:-105ad7d6:5284dcfe:26 status: ActionStatus.RUNNING >, session=#628928149)
Hello testTPCSFSB2a, this is xpctest.TestTPCSFSB2@54d2661d (em=org.jboss.as.jpa.container.TransactionScopedEntityManager@412e256c, identityHashCode=1093543276, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 0:ffff7f000002:-105ad7d6:5284dcfe:2a status: ActionStatus.RUNNING >, session=#1016788706)
Hello testTPCSFSB2b, this is xpctest.TestTPCSFSB2@66944e1f (em=org.jboss.as.jpa.container.TransactionScopedEntityManager@129509d6, identityHashCode=311757270, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 0:ffff7f000002:-105ad7d6:5284dcfe:2e status: ActionStatus.RUNNING >, session=#1991821857)
Hello testXPCSFSB1a, this is xpctest.TestXPCSFSB1@1bd7615 (em=ExtendedEntityManager [xpc-wildfly.ear#xpctestPU], identityHashCode=1033067927, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 0:ffff7f000002:-105ad7d6:5284dcfe:32 status: ActionStatus.RUNNING >, session=#367363094)
Hello testXPCSFSB1b, this is xpctest.TestXPCSFSB1@914d6b (em=ExtendedEntityManager [xpc-wildfly.ear#xpctestPU], identityHashCode=1131523095, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 0:ffff7f000002:-105ad7d6:5284dcfe:35 status: ActionStatus.RUNNING >, session=#1540963480)
Hello testXPCSFSB2a, this is xpctest.TestXPCSFSB2@65e936e6 (em=ExtendedEntityManager [xpc-wildfly.ear#xpctestPU], identityHashCode=840133199, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 0:ffff7f000002:-105ad7d6:5284dcfe:38 status: ActionStatus.RUNNING >, session=#413696568)
Hello testXPCSFSB2b, this is xpctest.TestXPCSFSB2@46fdc558 (em=ExtendedEntityManager [xpc-wildfly.ear#xpctestPU], identityHashCode=1051146449, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 0:ffff7f000002:-105ad7d6:5284dcfe:3b status: ActionStatus.RUNNING >, session=#1417888121)
Everything runs fine!
Worth mentioning:
- Each call gets its own transaction and its own session (as expected).
- Calls to SLSB of the same bean class get the same bean instance (which is ok, IMHO, as they come from the pool) and the same EntityManager instance (even though the Hibernate Session is different)
Now the test for situation #1: inside user transaction, first calls to SLSB, then transaction-scoped PC SFSB, then to XPC SFSB:
Hello testSLSB1a, this is xpctest.TestSLSB1@554f842c (em=org.jboss.as.jpa.container.TransactionScopedEntityManager@576e9075, identityHashCode=1466863733, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 0:ffff7f000002:-105ad7d6:5284dcfe:3e status: ActionStatus.RUNNING >, session=#213864434)
Hello testSLSB1b, this is xpctest.TestSLSB1@554f842c (em=org.jboss.as.jpa.container.TransactionScopedEntityManager@576e9075, identityHashCode=1466863733, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 0:ffff7f000002:-105ad7d6:5284dcfe:3e status: ActionStatus.RUNNING >, session=#213864434)
Hello testSLSB2a, this is xpctest.TestSLSB2@21cf0884 (em=org.jboss.as.jpa.container.TransactionScopedEntityManager@1f382373, identityHashCode=523772787, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 0:ffff7f000002:-105ad7d6:5284dcfe:3e status: ActionStatus.RUNNING >, session=#213864434)
Hello testSLSB2b, this is xpctest.TestSLSB2@21cf0884 (em=org.jboss.as.jpa.container.TransactionScopedEntityManager@1f382373, identityHashCode=523772787, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 0:ffff7f000002:-105ad7d6:5284dcfe:3e status: ActionStatus.RUNNING >, session=#213864434)
Hello testTPCSFSB1a, this is xpctest.TestTPCSFSB1@50f1e31f (em=org.jboss.as.jpa.container.TransactionScopedEntityManager@387631bd, identityHashCode=947270077, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 0:ffff7f000002:-105ad7d6:5284dcfe:3e status: ActionStatus.RUNNING >, session=#213864434)
Hello testTPCSFSB1b, this is xpctest.TestTPCSFSB1@643f700b (em=org.jboss.as.jpa.container.TransactionScopedEntityManager@d51598, identityHashCode=13964696, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 0:ffff7f000002:-105ad7d6:5284dcfe:3e status: ActionStatus.RUNNING >, session=#213864434)
Hello testTPCSFSB2a, this is xpctest.TestTPCSFSB2@54d2661d (em=org.jboss.as.jpa.container.TransactionScopedEntityManager@412e256c, identityHashCode=1093543276, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 0:ffff7f000002:-105ad7d6:5284dcfe:3e status: ActionStatus.RUNNING >, session=#213864434)
Hello testTPCSFSB2b, this is xpctest.TestTPCSFSB2@66944e1f (em=org.jboss.as.jpa.container.TransactionScopedEntityManager@129509d6, identityHashCode=311757270, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 0:ffff7f000002:-105ad7d6:5284dcfe:3e status: ActionStatus.RUNNING >, session=#213864434)
javax.ejb.EJBTransactionRolledbackException: JBAS011437: Found extended persistence context in SFSB invocation call stack but that cannot be used because the transaction already has a transactional context associated with it. This can be avoided by changing application code, either eliminate the extended persistence context or the transactional context. See JPA spec 2.0 section 7.6.3.1. Scoped persistence unit name=xpc-wildfly.ear#xpctestPU, persistence context already in transaction =org.hibernate.jpa.internal.EntityManagerImpl@42abf2ff, extended persistence context =ExtendedEntityManager [xpc-wildfly.ear#xpctestPU].
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:163)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:253)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:342)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239)
[...]
Caused by: javax.ejb.EJBException: JBAS011437: Found extended persistence context in SFSB invocation call stack but that cannot be used because the transaction already has a transactional context associated with it. This can be avoided by changing application code, either eliminate the extended persistence context or the transactional context. See JPA spec 2.0 section 7.6.3.1. Scoped persistence unit name=xpc-wildfly.ear#xpctestPU, persistence context already in transaction =org.hibernate.jpa.internal.EntityManagerImpl@42abf2ff, extended persistence context =ExtendedEntityManager [xpc-wildfly.ear#xpctestPU].
at org.jboss.as.jpa.container.ExtendedEntityManager.internalAssociateWithJtaTx(ExtendedEntityManager.java:133)
at org.jboss.as.jpa.container.SFSBCallStack.pushCall(SFSBCallStack.java:151)
at org.jboss.as.jpa.interceptor.SFSBInvocationInterceptor.processInvocation(SFSBInvocationInterceptor.java:54)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
at org.jboss.as.ejb3.component.stateful.StatefulSessionSynchronizationInterceptor.processInvocation(StatefulSessionSynchronizationInterceptor.java:127)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
[...]
Here we get the exception as soon as we try the first call to the first XPC SFSB.
As with JBAS5 it is interesting to see, that on all calls to SLSB and transaction scoped PC SFSB we get the same Hibernate Session. I didn't expect this.
Now situation #2: first call the first instance of XPC SFSB1, then call the second instance of SFSB1
Hello testXPCSFSB1a, this is xpctest.TestXPCSFSB1@3eed31ae (em=ExtendedEntityManager [xpc-wildfly.ear#xpctestPU], identityHashCode=1180219080, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 0:ffff7f000002:-105ad7d6:5284dcfe:48 status: ActionStatus.RUNNING >, session=#1783113868)
javax.ejb.EJBTransactionRolledbackException: JBAS011437: Found extended persistence context in SFSB invocation call stack but that cannot be used because the transaction already has a transactional context associated with it. This can be avoided by changing application code, either eliminate the extended persistence context or the transactional context. See JPA spec 2.0 section 7.6.3.1. Scoped persistence unit name=xpc-wildfly.ear#xpctestPU, persistence context already in transaction =ExtendedEntityManager [xpc-wildfly.ear#xpctestPU], extended persistence context =ExtendedEntityManager [xpc-wildfly.ear#xpctestPU].
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:163)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:253)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:342)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
at org.jboss.as.ejb3.remote.EJBRemoteTransactionPropagatingInterceptor.processInvocation(EJBRemoteTransactionPropagatingInterceptor.java:79)
[...]
Here we get the exception on the second call.
And finally situation #3: first call the first instance of XPC SFSB1, then call the first instance of SFSB2
Test with user transaction (situation #3)
Hello testXPCSFSB1a, this is xpctest.TestXPCSFSB1@5975dbe1 (em=ExtendedEntityManager [xpc-wildfly.ear#xpctestPU], identityHashCode=1219935913, flushMode=AUTO, tx=TransactionImple < ac, BasicAction: 0:ffff7f000002:-105ad7d6:5284dcfe:4e status: ActionStatus.RUNNING >, session=#1436511882)
javax.ejb.EJBTransactionRolledbackException: JBAS011437: Found extended persistence context in SFSB invocation call stack but that cannot be used because the transaction already has a transactional context associated with it. This can be avoided by changing application code, either eliminate the extended persistence context or the transactional context. See JPA spec 2.0 section 7.6.3.1. Scoped persistence unit name=xpc-wildfly.ear#xpctestPU, persistence context already in transaction =ExtendedEntityManager [xpc-wildfly.ear#xpctestPU], extended persistence context =ExtendedEntityManager [xpc-wildfly.ear#xpctestPU].
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:163)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:253)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:342)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
at org.jboss.as.ejb3.remote.EJBRemoteTransactionPropagatingInterceptor.processInvocation(EJBRemoteTransactionPropagatingInterceptor.java:79)
[...]
Again, we get the exception on the second call.
You can find the source code of my test implementation attached as tar archive containing the full Eclipse project structure.
Last, but not least I would like to elaborate on one point you mentioned in your last post: from my (i.e. the remote client) point of view this all is not about persistence context inheritance between session beans! On the remote client I do not expect to get the same persistence context of the same PU when calling methods on different session bean instances. I'm fine with having detached entities to work with and I do not expect lazy loading to work on the remote client. This is something I can deal with on the remote client (and I do since the old days of JEE5).
I just want to be able to control the transaction when I call the beans, even if (and up to now I expect that to be the case) all bean instances use different persistence context instances.