Uploaded image for project: 'TomEE'
  1. TomEE
  2. TOMEE-445

@RequestScoped @Stateful EJB beans are not destroyed after request completes

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.0
    • Fix Version/s: 1.5.1
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows 7 x64; Oracle JDK 1.7.0_07; tomee-web-profile-1.5.0.zip

      Description

      1. Create simple JSF+CDI+EJB application consisting of one JSF page and one EJB component:

      index.xhtml:
      ...
      <h:body>
      Current real date is: #

      {dateBean.currentDate()}

      </h:body>
      </html>

      EJB: DateBean.java:

      @Named
      @RequestScoped
      @Stateful
      public class DateBean {

      @PostConstruct
      private void init()

      { System.out.println("INIT: " + this); }

      @PreDestroy
      private void die()

      { System.out.println("DIE: " + this); }

      public String currentDate()

      { System.out.println("Method was called..."); return "" + new Date(); }

      }

      2. Run the application. EJB method works OK, the current date is getting printed. Refresh browser window several times, Tomee log file will print this:

      INIT: beans.DateBean@1ac52c5
      Method was called...
      INIT: beans.DateBean@792217
      Method was called...
      INIT: beans.DateBean@1438814
      Method was called...

      Method annotated with @PreDestroy never gets called.

      3. Remove annotation @Stateful (thus EJB bean becomes simple CDI bean), try again.
      This time each INIT log message is followed by DIE message.

      Conclusion: @RequestScoped + @PreDestroy is working on CDI beans, but not on EJB beans.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              donatasc Donatas Ciuksys
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: