<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    SFSB state is not beeing maintained in jboss5.1
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/santos2178">Santos Mandre</a> in <i>EJB3</i> - <a href="https://community.jboss.org/message/740619#740619">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hi Guys,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span class="postbody">I am using <a class="jive-link-external-small" href="http://www.coderanch.com/forums/f-63/JBoss" target="_new">jboss</a> 5.1 and have written a SFSB - BillItemsListFacadBean which i am trying to invoke from a SLSB - BillFacadBean. The basic purpose of this SFSB is to store list of billitems that were selected as part of generating a document .No database calls involved in the SFSB. It has got 2 simple methods updateDeliveryMemoSelectionList and fetchDeliveryMemoSelectionList .updateDeliveryMemoSelectionList&#160; updates the instance variable arrCummulativeDMSelectionList , which is a list and fetchDeliveryMemoSelectionList&#160; returns this to the calling program. I am using the below code in a <a class="jive-link-external-small" href="http://www.coderanch.com/forums/f-58/Struts" target="_new">struts</a> action class to update the instance variable of the SFSB <br/> <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; BillItemsListFacadBeanInterface billItemsListFacadBean = null; <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;try{ <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;billItemsListFacadBean = (BillItemsListFacadBeanInterface) new <a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/javax/naming/InitialContext.html" target="_new">InitialContext</a>().lookup("inticraftEAR/BillItemsListFacadBean/local"); <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}catch(<a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/javax/naming/NamingException.html" target="_new">NamingException</a> name){ <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;throw new ECSystemException(name.getMessage(),BillCreationAction.class.getName(),METHOD_NAME); <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html" target="_new">ArrayList</a>&lt;<a class="jive-link-external-small" href="http://www.coderanch.com/t/410859/java/java/String-StringBuffer-StringBuilder-Performance" target="_new">String</a>&gt; arrCheckedItems = new <a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html" target="_new">ArrayList</a>&lt;String&gt;(); <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/java/util/StringTokenizer.html" target="_new">StringTokenizer</a> billitemString = new <a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/java/util/StringTokenizer.html" target="_new">StringTokenizer</a>(request.getParameter("dmCheckBoxSelectionList_Hidden"),","); <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;while(billitemString.hasMoreTokens()){ <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;String billitem_id = billitemString.nextToken(); <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;arrCheckedItems.add(billitem_id); <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html" target="_new">ArrayList</a>&lt;String&gt; arrUnCheckedItems = new <a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html" target="_new">ArrayList</a>&lt;String&gt;(); <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/java/util/StringTokenizer.html" target="_new">StringTokenizer</a> billitemString2 = new <a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/java/util/StringTokenizer.html" target="_new">StringTokenizer</a>(request.getParameter("dmCheckBoxUnSelectionList_Hidden"),","); <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;while(billitemString2.hasMoreTokens()){ <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;String billitem_id = billitemString2.nextToken(); <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;arrUnCheckedItems.add(billitem_id); <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;billItemsListFacadBean.updateDeliveryMemoSelectionList(arrCheckedItems, arrUnCheckedItems); <br/> <br/> After this now when i try to access this variable in BillFacadBean(SLSB)&#160; using the below code the value of the instance variable(arrCummulativeDMSelectionList) of the SFSB is null and hence the method <br/> fetchDeliveryMemoSelectionList returns an empty arraylist. <br/> <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; BillItemsListFacadBeanInterface billItemsListFacadBean = null; <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;try{ <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;billItemsListFacadBean = (BillItemsListFacadBeanInterface) new <a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/javax/naming/InitialContext.html" target="_new">InitialContext</a>().lookup("inticraftEAR/BillItemsListFacadBean/local"); <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}catch(<a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/javax/naming/NamingException.html" target="_new">NamingException</a> name){ <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;throw new ECSystemException(name.getMessage(),BillFacadBean.class.getName(),METHOD_NAME); <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if(null != billItemsListFacadBean){ <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;arrSelectedBillItems = billItemsListFacadBean.fetchDeliveryMemoSelectionList(); <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} <br/> <br/> Code of SFSB BillItemsListFacadBean&#160; is as below: <br/> <br/> package com.inticraft.facad; <br/> <br/> import <a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html" target="_new">java.util.ArrayList</a>; <br/> import <a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/java/util/Iterator.html" target="_new">java.util.Iterator</a>; <br/> import <a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/java/util/List.html" target="_new">java.util.List</a>; <br/> <br/> import <a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/javax/annotation/PostConstruct.html" target="_new">javax.annotation.PostConstruct</a>; <br/> import <a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/javax/annotation/PreDestroy.html" target="_new">javax.annotation.PreDestroy</a>; <br/> import <a class="jive-link-external-small" href="http://docs.oracle.com/javaee/6/api/javax/ejb/PostActivate.html" target="_new">javax.ejb.PostActivate</a>; <br/> import <a class="jive-link-external-small" href="http://docs.oracle.com/javaee/6/api/javax/ejb/PrePassivate.html" target="_new">javax.ejb.PrePassivate</a>; <br/> import <a class="jive-link-external-small" href="http://docs.oracle.com/javaee/6/api/javax/ejb/Remove.html" target="_new">javax.ejb.Remove</a>; <br/> import <a class="jive-link-external-small" href="http://docs.oracle.com/javaee/6/api/javax/ejb/Stateful.html" target="_new">javax.ejb.Stateful</a>; <br/> import <a class="jive-link-external-small" href="http://docs.oracle.com/javaee/6/api/javax/interceptor/Interceptors.html" target="_new">javax.interceptor.Interceptors</a>; <br/> <br/> import com.inticraft.ejbutil.CommitAndCloseInterceptor; <br/> import com.inticraft.ejbutil.LoggingInterceptor; <br/> import com.inticraft.exceptions.ECException; <br/> <br/> /** <br/>&#160; * Session Bean implementation class BillItemsListFacadBean <br/>&#160; */ <br/> @Interceptors({LoggingInterceptor.class}) <br/> @Stateful <br/> public class BillItemsListFacadBean implements BillItemsListFacadBeanInterface { <br/> &#160;&#160;&#160;&#160;&#160;private List &lt;String&gt; arrCummulativeDMSelectionList; <br/> &#160;&#160;&#160;&#160;&#160;private String first_element; <br/>&#160;&#160;&#160;&#160; /** <br/>&#160;&#160;&#160;&#160;&#160; * Default constructor. <br/>&#160;&#160;&#160;&#160;&#160; */ <br/>&#160;&#160;&#160;&#160; public BillItemsListFacadBean() { <br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // TODO Auto-generated constructor stub <br/>&#160;&#160;&#160;&#160; } <br/> <br/>&#160;&#160;&#160;&#160; @PostConstruct <br/>&#160;&#160;&#160;&#160; @PostActivate <br/>&#160;&#160;&#160;&#160; public void openConnection(){ <br/> <br/>&#160;&#160;&#160;&#160; } <br/> <br/>&#160;&#160;&#160;&#160; @PrePassivate <br/>&#160;&#160;&#160;&#160; @PreDestroy <br/>&#160;&#160;&#160;&#160; public void cleanup() { <br/> <br/> <br/>&#160;&#160;&#160;&#160; } <br/> <br/>&#160;&#160;&#160;&#160; @Remove <br/>&#160;&#160;&#160;&#160; @Interceptors({CommitAndCloseInterceptor.class}) <br/>&#160;&#160;&#160;&#160; public void closeDM() throws ECException{ <br/>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;arrCummulativeDMSelectionList = null; <br/>&#160;&#160;&#160;&#160; } <br/> <br/> <br/> <br/> &#160;&#160;&#160;&#160;&#160;@Interceptors({CommitAndCloseInterceptor.class}) <br/>&#160;&#160;&#160;&#160; public void updateDeliveryMemoSelectionList(<a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html" target="_new">ArrayList</a>&lt;String&gt; arrSelectedItems , <a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html" target="_new">ArrayList</a>&lt;String&gt;arrUnSelectedItems) throws ECException { <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;arrCummulativeDMSelectionList = new <a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html" target="_new">ArrayList</a>&lt;String&gt;(); <br/>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;//Step1 iterate through the unselecteditems and remove from the cummulative list if any entry matches <br/>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;Iterator &lt;String&gt;it1 = arrUnSelectedItems.iterator(); <br/>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;while(it1.hasNext()){ <br/>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;String unSelectedItem = (String)it1.next(); <br/>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if(arrCummulativeDMSelectionList.contains(unSelectedItem)){ <br/>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;arrCummulativeDMSelectionList.remove(unSelectedItem); <br/>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} <br/>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;} <br/>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;Iterator &lt;String&gt;it2 = arrSelectedItems.iterator(); <br/>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;while(it2.hasNext()){ <br/>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;String selectedItem = (String)it2.next(); <br/>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if(!arrCummulativeDMSelectionList.contains(selectedItem)){ <br/>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;arrCummulativeDMSelectionList.add(selectedItem); <br/>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;first_element = selectedItem; <br/>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} <br/>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;} <br/>&#160;&#160;&#160;&#160; } <br/> <br/> &#160;&#160;&#160;&#160;&#160;@Interceptors({CommitAndCloseInterceptor.class}) <br/>&#160;&#160;&#160;&#160; public <a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html" target="_new">ArrayList</a>&lt;String&gt; fetchDeliveryMemoSelectionList() throws ECException { <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if(null == arrCummulativeDMSelectionList){ <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;return new <a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html" target="_new">ArrayList</a>(); <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}else{ <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;return new <a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html" target="_new">ArrayList</a>(arrCummulativeDMSelectionList); <br/> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} <br/> <br/>&#160;&#160;&#160;&#160; } <br/> <br/> <br/> } <br/> <br/> I am not understaning , why is this variable value null always ie the STATE IS NOT BEING MAINTAINED. Also another thing that i observed was in the jobss jmx console , every time this SFSB was accessed the count got incrmented by 1 , which is making me think , every time this bean is called a new instance of the bean is created , instead of returning the already created instance. I am going nuts over this . any help is greatly appreciated. Thanks a ton in advance and also please let me know if you would need any other information. <br/></span></p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/740619#740619">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in EJB3 at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>