2 Replies Latest reply on Jan 19, 2010 4:30 PM by Youssef El Maroufy

    Stateful not keep data

    Youssef El Maroufy Newbie


      I hope i'm in the correct sub-furum

      I have a problem with Stateful that do not keep data between methods calls;

      public class ShoppingCart implements ShoppingCartLocal {
           private List<CartItem> cartItems;
           public List<CartItem> getCartItems() {
                return cartItems;
           public void initialize() {
                cartItems = new ArrayList<CartItem>();
           public void clear() {
                cartItems = null;

      the method initialize() is executed on each call !


      I'm using JBoss 5.1, and the Stateful is injected in a Managed Bean


      public class ProductBusinessDelegate {
           ProductBusinessLocal productBusiness;
           ShoppingCartLocal shoppingCart;
           public List<CartItem> getCartItems(){
                return shoppingCart.getCartItems();
           public ProductBusinessDelegate() {