Version 8

    Aligning Timeout Values for HTTP Session and JBoss Default SFSB


    (Work in Progress)



    The aim of this document is to describe the changes that are necessary to align HTTP and SFSB timeout values between a Seam application and its JBoss runtime environment.  In the Seam forums there have been many cases where "Could not destroy component" exceptions are thrown during destruction phase of a stateful session bean.  One of the causes of these exceptions is down to the timeout values of HTTP and SFSB being different.  (TODO: improve explanation)


    A typical exception would look like this:


    2006-11-30 02:52:03,664 WARN  [org.jboss.seam.contexts.Contexts] Could not destroy component: OrderSession
    javax.ejb.EJBNoSuchObjectException: Could not find Stateful bean: 41z4l26-wb41k6-ev4j007b-1-ev4jirql-bw
            at org.jboss.ejb3.cache.simple.SimpleStatefulCache.get(
            at org.jboss.ejb3.stateful.StatefulRemoveInterceptor.removeSession(
            at org.jboss.ejb3.stateful.StatefulRemoveInterceptor.invoke(
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(
            at org.jboss.ejb3.ENCPropagationInterceptor.invoke(
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(
            at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(
            at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(
            at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(
            at $Proxy219.destroy(Unknown Source)
            at x.x.OrderSession$$FastClassByCGLIB$$e5185c52.invoke(<generated>)
            at net.sf.cglib.proxy.MethodProxy.invoke(
            at org.jboss.seam.intercept.RootInvocationContext.proceed(
            at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(
            at org.jboss.seam.intercept.SeamInvocationContext.proceed(
            at org.jboss.seam.interceptors.RemoveInterceptor.removeIfNecessary(


    HTTP Session Timeout


    To set the HTTP timeout value, locate the following file within your application's war archive and either edit or add the following session-timeout value to your needs.  This example uses 15 minutes.  If no session-timeout value was specified, then the default timeout value is 30 minutes.








    Note: Value is in minutes;


    SFSB Timeout


    You have 2 choices here:


    1. you can set the SFSB timeout on a per class basis using the @CacheConfig annotation; or

    2. you can set the default SFSB value for your JBoss environment that will apply to all session beans.


    Using the @CacheConfig annotation, you may set the session timeout for a stateful session bean as follows:


    public class MyAccountBean implements MyAccount, Serializable


    Note. Value is in seconds: 900 seconds = 15 minutes as specified in the HTTP timeout - set this to your needs; This must be done for each session bean in your application.



    Setting the default SFSB timeout requires two JBoss configuration files to be set:


    Please note that setting the config in this way is required for every server that the Seam code is deployed to and applies to all EJB3 applications on that server.


    File 1:



    Find entry matching '

    <domain name="Stateful Bean" extends="Base Stateful Bean" inheritBindings="true">



    <domain name="Stateful Bean" extends="Base Stateful Bean" inheritBindings="true">
       <domain name="Stateful Bean" extends="Base Stateful Bean" inheritBindings="true">
          <!-- Align this value with session timeout in web.xml -->
          <annotation expr="!class(@org.jboss.annotation.ejb.cache.simple.CacheConfig) AND !class @org.jboss.annotation.ejb.Clustered)">
             @org.jboss.annotation.ejb.cache.simple.CacheConfig (maxSize=100000, idleTimeoutSeconds=900)



    If you are using EJB2, you will need to set the Set the idleTimeoutSeconds value in the standardjboss.xml file.  Please note that if you are using EJB3, you DO NOT need to change the standardjboss.xml file



    File 2:



    Find entry for '

    <container-name>Standard Stateful SessionBean</container-name>



          <container-name>Standard Stateful SessionBean</container-name>




    Note. Values are in seconds: 900 seconds = 15 minutes as specified in the HTTP timeout - set this to your needs;



    As a final note, this example sets HTTP and SFSB values to be exactly the same. It is sometimes recommended that the SFSB timeouts are set to be longer than the HTTP session timeout.  (TODO: clarify this)


    That is all. Aligning these timeout values will help prevent those "Could not destroy component: XXXX" exceptions in some cases.  Please be aware that there are other causes of this exception too such as the serialisability of the SFSB.  Please refer to the JBoss Seam forum if you are still getting the timeout errors.


    Further information and discussion, see references.





    1. Original Discussion Topic

    2. How do the timeouts work with EJB3 Stateful Beans