The Runtime Exception if thrown in a bean is propogated in the transaction boundary of the container till it is handled.
Whenever the runtime exception is throw from a bean, the bean is destroyed.
So if the stateless session bean throws a runtime exception and the callee is a stateful session bean, it'll be destroyed.
You are almost right on why it happens.
Marking the execution on the stateless bean as requires new would help only to control the transaction boundaries.
If you do not want the stateful bean to be destroyed then catch the exception from the bean, wrap it with an application exception and return to the client.
This way the transaction is rolled back and the client is informed of the exception.
Lastly, for any bean the tx attribute can be specified in it's deployment descriptor on a per method basis.
Regards
Rajat
On 7/4/05, Karen <[EMAIL PROTECTED]> wrote:
Hi,
Don't know if I should asked it here caused it's JBoss related. Since no reply
from JBoss site, thought to ask for advise here.
I'm using JBoss 4.0. I have a container-managed stateful session bean which
will call a stateless session bean for some business logics. What I'm trying
to do is to simulate a transaction rollback scenario to see my beans'
behaviour.
Something I don't understand, when I get a
"TransactionRolledbackLocalException" in the stateless session bean, the
caller bean (stateful) will do an activation when I re-invoke the method
call. I've simulated this scenario few times, and each time, it gives the
same result. From the log files, it didn't show the stateful session bean
passivated. It only shows attempting to activate.
==========================================
2005-07-04 12:09:13,520 DEBUG
[org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager ] Attempting to
activate; [EMAIL PROTECTED]
2005-07-04 12:09:13,521 DEBUG
[org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager] Reading session
state
from: /opt/jboss- 4.0/server/default/tmp/sessions/ModSession-eaq5cb77-9/eaq71zbn-14.ser
2005-07-04 12:09:13,532 DEBUG [org.jboss.ejb.plugins.AbstractInstanceCache]
Activation failure
javax.ejb.EJBException: Could not activate; failed to restore state;
CausedByException is:
/opt/jboss-4.0/server/default/tmp/sessions/ModSession-eaq5cb77-9/eaq71zbn-14.ser
(No such file or directory)
at
org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager.activateSession (StatefulSessionFilePersistenceManager.java:340)
at
org.jboss.ejb.plugins.StatefulSessionInstanceCache.activate(StatefulSessionInstanceCache.java:99)
at
org.jboss.ejb.plugins.AbstractInstanceCache.doActivate (AbstractInstanceCache.java:412)
at
org.jboss.ejb.plugins.StatefulSessionInstanceCache.doActivate(StatefulSessionInstanceCache.java:115)
at
org.jboss.ejb.plugins.AbstractInstanceCache.get(AbstractInstanceCache.java :109)
at
org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor.invoke(StatefulSessionInstanceInterceptor.java:217)
at
org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java :48)
at
org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:313)
at
org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:146)
at
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
at
org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke (ProxyFactoryFinderInterceptor.java:122)
at
org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
at org.jboss.ejb.Container.invoke(Container.java:870)
at sun.reflect.GeneratedMethodAccessor83.invoke (Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.jboss.mx.interceptor.ReflectedDispatcher.invoke (ReflectedDispatcher.java:144)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
at
org.jboss.mx.server.AbstractMBeanInvoker.invoke (AbstractMBeanInvoker.java:249)
at
org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
at
org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java :805)
at
org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:406)
at sun.reflect.GeneratedMethodAccessor85.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run (Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at
sun.rmi.transport.tcp.TCPTransport.handleMessages (TCPTransport.java:460)
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:595)
java.io.FileNotFoundException: /opt/jboss-4.0 /server/default/tmp/sessions/ModSession-eaq5cb77-9/eaq71zbn-14.ser
(No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java :106)
at
org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager$FISAction.run(StatefulSessionFilePersistenceManager.java:507)
at java.security.AccessController.doPrivileged(Native Method)
at
org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager$FISAction.open(StatefulSessionFilePersistenceManager.java:516)
at
org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager.activateSession (StatefulSessionFilePersistenceManager.java:322)
at
org.jboss.ejb.plugins.StatefulSessionInstanceCache.activate(StatefulSessionInstanceCache.java:99)
at
org.jboss.ejb.plugins.AbstractInstanceCache.doActivate (AbstractInstanceCache.java:412)
at
org.jboss.ejb.plugins.StatefulSessionInstanceCache.doActivate(StatefulSessionInstanceCache.java:115)
at
org.jboss.ejb.plugins.AbstractInstanceCache.get(AbstractInstanceCache.java :109)
at
org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor.invoke(StatefulSessionInstanceInterceptor.java:217)
at
org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java :48)
at
org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:313)
at
org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:146)
at
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
at
org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke (ProxyFactoryFinderInterceptor.java:122)
at
org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
at org.jboss.ejb.Container.invoke(Container.java:870)
at sun.reflect.GeneratedMethodAccessor83.invoke (Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.jboss.mx.interceptor.ReflectedDispatcher.invoke (ReflectedDispatcher.java:144)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
at
org.jboss.mx.server.AbstractMBeanInvoker.invoke (AbstractMBeanInvoker.java:249)
at
org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
at
org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java :805)
at
org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:406)
at sun.reflect.GeneratedMethodAccessor85.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run (Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at
sun.rmi.transport.tcp.TCPTransport.handleMessages (TCPTransport.java:460)
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:595)
==========================================
Any idea why is this happened?
My own thought is, do correct me if I'm wrong, the statelss session bean by
default is using the same tx as the stateful session (for container-managed)
bean in JBoss. When "TransactionRolledbackLocalException" occurred, both
beans is marked as "rollback only", hence caused the stateful session gone?
My objective is not to cause the stateful session gone/passivated even there's
a transaction rollback in the stateless session bean. One solution I could
think of is to set the stateless session to Bean-managed and set
"RequiresNew" tx attribute to the stateless session bean methods.
Can I set any tx attribute when it is a container-managed bean?
Any better suggestion? Do advise.
Thank you.
Regards,
Karen
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
--
Music, states of happiness, mythology, faces belabored by time, certain twilights and certain places try to tell us something, or have said something we should not have missed, or are about to say something; this imminence of a revelation which does not occur is, perhaps, the aesthetic phenomenon.
--Jorge Louis Borges ("The Wall and the Books") =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".