<!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;"> </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  updates the instance variable arrCummulativeDMSelectionList , which is a list and fetchDeliveryMemoSelectionList  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/>                         BillItemsListFacadBeanInterface billItemsListFacadBean = null; <br/>                try{ <br/>                     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/>                }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/>                     throw new ECSystemException(name.getMessage(),BillCreationAction.class.getName(),METHOD_NAME); <br/>                } <br/>                <a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html" target="_new">ArrayList</a><<a class="jive-link-external-small" href="http://www.coderanch.com/t/410859/java/java/String-StringBuffer-StringBuilder-Performance" target="_new">String</a>> 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><String>(); <br/>                <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/>                while(billitemString.hasMoreTokens()){ <br/>                     String billitem_id = billitemString.nextToken(); <br/>                     arrCheckedItems.add(billitem_id); <br/>                } <br/>                <a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html" target="_new">ArrayList</a><String> 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><String>(); <br/>                <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/>                while(billitemString2.hasMoreTokens()){ <br/>                     String billitem_id = billitemString2.nextToken(); <br/>                     arrUnCheckedItems.add(billitem_id); <br/>                } <br/>                billItemsListFacadBean.updateDeliveryMemoSelectionList(arrCheckedItems, arrUnCheckedItems); <br/> <br/> After this now when i try to access this variable in BillFacadBean(SLSB)  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/>                BillItemsListFacadBeanInterface billItemsListFacadBean = null; <br/>           try{ <br/>                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/>           }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/>                throw new ECSystemException(name.getMessage(),BillFacadBean.class.getName(),METHOD_NAME); <br/>           } <br/>           if(null != billItemsListFacadBean){ <br/>                arrSelectedBillItems = billItemsListFacadBean.fetchDeliveryMemoSelectionList(); <br/>           } <br/> <br/> Code of SFSB BillItemsListFacadBean  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/>  * Session Bean implementation class BillItemsListFacadBean <br/>  */ <br/> @Interceptors({LoggingInterceptor.class}) <br/> @Stateful <br/> public class BillItemsListFacadBean implements BillItemsListFacadBeanInterface { <br/>      private List <String> arrCummulativeDMSelectionList; <br/>      private String first_element; <br/>     /** <br/>      * Default constructor. <br/>      */ <br/>     public BillItemsListFacadBean() { <br/>         // TODO Auto-generated constructor stub <br/>     } <br/> <br/>     @PostConstruct <br/>     @PostActivate <br/>     public void openConnection(){ <br/> <br/>     } <br/> <br/>     @PrePassivate <br/>     @PreDestroy <br/>     public void cleanup() { <br/> <br/> <br/>     } <br/> <br/>     @Remove <br/>     @Interceptors({CommitAndCloseInterceptor.class}) <br/>     public void closeDM() throws ECException{ <br/>          arrCummulativeDMSelectionList = null; <br/>     } <br/> <br/> <br/> <br/>      @Interceptors({CommitAndCloseInterceptor.class}) <br/>     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><String> arrSelectedItems , <a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html" target="_new">ArrayList</a><String>arrUnSelectedItems) throws ECException { <br/>           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><String>(); <br/>          //Step1 iterate through the unselecteditems and remove from the cummulative list if any entry matches <br/>          Iterator <String>it1 = arrUnSelectedItems.iterator(); <br/>          while(it1.hasNext()){ <br/>               String unSelectedItem = (String)it1.next(); <br/>               if(arrCummulativeDMSelectionList.contains(unSelectedItem)){ <br/>                    arrCummulativeDMSelectionList.remove(unSelectedItem); <br/>               } <br/>          } <br/>          Iterator <String>it2 = arrSelectedItems.iterator(); <br/>          while(it2.hasNext()){ <br/>               String selectedItem = (String)it2.next(); <br/>               if(!arrCummulativeDMSelectionList.contains(selectedItem)){ <br/>                    arrCummulativeDMSelectionList.add(selectedItem); <br/>                    first_element = selectedItem; <br/>               } <br/>          } <br/>     } <br/> <br/>      @Interceptors({CommitAndCloseInterceptor.class}) <br/>     public <a class="jive-link-external-small" href="http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html" target="_new">ArrayList</a><String> fetchDeliveryMemoSelectionList() throws ECException { <br/>           if(null == arrCummulativeDMSelectionList){ <br/>                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/>           }else{ <br/>                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/>           } <br/> <br/>     } <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>