Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9283359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:36:31+00:00 2026-06-18T18:36:31+00:00

This is a JSF 2 app running on WAS8.0. Here is the code for

  • 0

This is a JSF 2 app running on WAS8.0. Here is the code for the “backing” bean of one page.

    @Named("mySessionBean")
    @SessionScoped
    @Stateful
    @LocalBean
    @StatefulTimeout(unit = TimeUnit.MINUTES, value = 10)
    public class MySessionBean implements Serializable {
        @PostConstruct
        public void init()
        {
             System.out.println("start MySessionBean: " + this.hashCode());
         }

        @PreDestroy
        public void cleanup()
        {
             System.out.println("destroy MySessionBean: " + this.hashCode());
         }
        ....
    }

The session timeout value set in web.xml is smaller than the bean’s timeout. When I run the app, I see the printout from @PostConstruct but never see the one from @PreDestroy. I have tried the following 2 scenarios: 1. logout – invalidateSession; 2. simply wait until the session expires.

I’m not the designer of the app. The designer insists to make all the backing bean as a stateful session bean. I think the more mainstream approach would be just making them CDI bean. But anyway, when I do change the annotation to CDI only, I start getting the printout from @PreDestroy as well

    @Named("mySessionBean")
    @SessionScoped
    public class MySessionBean implements Serializable {
    .....

My question is, what is the reason that I’m not getting the @PreDestroy method call in the first case? If I can’t see the @PreDestroy get called, is there any other ways that I can trace the lifecycle of the “backing” beans (in this case, a stateful session bean). Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T18:36:32+00:00Added an answer on June 18, 2026 at 6:36 pm

    Look at this section of the Java EE 6 Tutorial, it shows the lifecycle of stateful session beans. The PreDestroy method is only called when the bean is explicitly removed from the client code, calling a method annotated with @Remove.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this JSF page trying to load a GWT app. The page works
I have this JSF page: <div id=settingsdiv style=width:350px; height:400px; position:absolute; background-color:r; top:20px; left:1px> <h:form>
I want to implement this JSF page with pagination and sorting. Unfortunately Netbeans shows
i have a jsf application running on tomcat 6.0 and somewhere in the app
Here is my scenario: I have my-jsf-app.war (JSF 1.2 application) and daos-and-entities.har (Hibernate 3.3.1)
I have a JSF 2.1 (MyFaces) app running using several Session Beans (All the
I have a JSF 2.0 application(App#1) that has a managed Session Scoped bean that
Based on this post http://www.adam-bien.com/roller/abien/entry/ejb_3_1_killed_the I use in my app @Named @Stateless bean for
I have just upgraded an app previously running on Richfaces 3and JSF 1.2 to
So, I've seen this post: JSF - session scoped bean shared by browsers on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.