I am having a problem with transactions and bean managed persistence. In my example, I have session beans SA and SB and entity beans EA and EB. I call a method in SA from a client, which creates SB and calls a method on it. The method in SB finds entity EB and modifies a value. Then, SA creates a new EA. Because of a unique constraint in my database on EA, the insert fails, which should rollback the entire transaction. All four beans have trans-attribute Required. However, when I run, the change to EB is not rolled back...
So, the thread of execution is:
client
SA
SB
EB
EA (failure, should roll back)
I then changed the trans-attributes to Mandatory for all beans except SA,
and when I run, SA gets a TransactionRequiredException thrown from SB, when
it tries to find EB by primary key. This seems to indicate that the
transaction was "lost" or exited prematurely. Please, let me know if I am
doing anything wrong, or if someone has seen something like this before.
It is important to note, I have tried with a stateful session bean where I
manage the transaction and rollback works properly. I think I have ruled
out configuration issues. I also tried managing the transaction in the
above code and this hasn't helped.
Thanks
[Default] java.rmi.ServerException: Transaction rolled back; nested
exception is
:
javax.transaction.TransactionRequiredException: Transaction
Required, re
ad the spec!
[Default] javax.transaction.TransactionRequiredException: Transaction
Required,
read the spec!
[Default] at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(Tx
InterceptorCMT.java:544)
[Default]
[Default] at
org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxIntercept
orCMT.java:86)
[Default]
[Default] at
org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(Security
Interceptor.java:103)
[Default]
[Default] at
org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogIntercepto
r.java:106)
[Default]
[Default] at
org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java
:420)
[Default]
[Default] at
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke
Home(JRMPContainerInvoker.java:437)
[Default]
[Default] at
org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invokeHome(Ho
meProxy.java:237)
[Default]
[Default] at
org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invoke(HomePr
oxy.java:182)
[Default]
[Default] at $Proxy58.findByPrimaryKey(Unknown Source)
[Default]
[Default] at
com.armanta.ejb.identifier.IdentifierMasterBean.getNextIndex(
IdentifierMasterBean.java:23)
[Default]
[Default] at java.lang.reflect.Method.invoke(Native Method)
[Default]
[Default] at
org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.
invoke(StatelessSessionContainer.java:543)
[Default]
[Default] at
org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBM
T.java:276)
[Default]
[Default] at
org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.inv
oke(StatelessSessionInstanceInterceptor.java:87)
[Default]
[Default] at
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInte
rceptor.java:128)
[Default]
[Default] at
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.ja
va:195)
[Default]
[Default] at
org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessi
onContainer.java:286)
[Default]
[Default] at
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke
(JRMPContainerInvoker.java:483)
[Default]
[Default] at
org.jboss.ejb.plugins.jrmp.interfaces.GenericProxy.invokeCont
ainer(GenericProxy.java:335)
[Default]
[Default] at
org.jboss.ejb.plugins.jrmp.interfaces.StatelessSessionProxy.i
nvoke(StatelessSessionProxy.java:123)
[Default]
[Default] at $Proxy30.getNextIndex(Unknown Source)
[Default]
[Default] at
com.armanta.ejb.portfolio.PortfolioMasterBean.createNewPortfo
lio(PortfolioMasterBean.java:29)
[Default]
[Default] at java.lang.reflect.Method.invoke(Native Method)
[Default]
[Default] at
org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.
invoke(StatelessSessionContainer.java:543)
[Default]
[Default] at
org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBM
T.java:276)
[Default]
[Default] at
org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.inv
oke(StatelessSessionInstanceInterceptor.java:87)
[Default]
[Default] at
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInte
rceptor.java:128)
[Default]
[Default] at
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.ja
va:195)
[Default]
[Default] at
org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessi
onContainer.java:286)
[Default]
[Default] at
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke
(JRMPContainerInvoker.java:393)
[Default]
[Default] at java.lang.reflect.Method.invoke(Native Method)
[Default]
[Default] at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
[Default]
[Default] at sun.rmi.transport.Transport$1.run(Unknown Source)
[Default]
[Default] at java.security.AccessController.doPrivileged(Native
Method)
[Default]
[Default] at sun.rmi.transport.Transport.serviceCall(Unknown Source)
[Default]
[Default] at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown
Sou
rce)
[Default]
[Default] at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unkn
own Source)
[Default]
[Default] at java.lang.Thread.run(Unknown Source)
[Default]
winmail.dat
Description: application/ms-tnef
