glassfish
  1. glassfish
  2. GLASSFISH-16824

Stateful EJB state not preserved with keepstate=true

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.1
    • Fix Version/s: None
    • Component/s: ejb_container
    • Labels:
      None

      Description

      For a vanilla Java EE 6 project with the following stateful EJB:

      /*

      • To change this template, choose Tools | Templates
      • and open the template in the editor.
        */
        package org.glassfish.samples;

      import java.io.Serializable;
      import java.util.ArrayList;
      import javax.annotation.PostConstruct;
      import javax.ejb.Stateful;

      /**
      *

      • @author arungupta
        */
        @Stateful
        public class NewSessionBean implements Serializable {

      private ArrayList items;

      @PostConstruct
      public void init()

      { items = new ArrayList(); }

      public void addItem(String item)

      { items.add(item); }

      public void removeItem(String item)

      { items.remove(item); }

      public ArrayList getItems()

      { return items; }

      }

      Injected in a Servlet as:

      @Inject NewSessionBean bean;

      used as:

      bean.addItem("1");
      bean.addItem("2");
      bean.addItem("3");
      out.println(bean.getItems());

      and deployed as:

      ~/tools/glassfish/3.1/glassfish3/glassfish/bin/asadmin deploy --force=true --keepstate=true dist/WebApplication44.war

      The state is not preserved across multiple redeploys. Each redeploy shows the array list initialized to blank. Tried initializing it outside @PostConstruct as well.

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Mahesh Kannan
            Reporter:
            arungupta
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: