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

  • Home
  • SEARCH
  • 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 7764401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:54:07+00:00 2026-06-01T14:54:07+00:00

Summary: does anyone know how to get @PreDestroy to get triggered on recycling\ timeout

  • 0

Summary: does anyone know how to get @PreDestroy to get triggered on recycling\ timeout of an Application Scope managed bean?

I posted a question a couple of weeks ago about “scheduled agents”: 30 sec periodic task to poll external web service and cache data
…which I implemented successfully so far using a Thread (at present went with this method as all the logic contained within the design of the database), I can start\ cancel\ pause\ restart the Thread successfully from my Application Scope backing bean. But a side effect is that when the backing bean that initiates the Thread is recycled, the Thread keeps running. I have a method that calls my cancel Thread method using @PreDestroy in my Application Scope bean, but it appears this does not get called.

I did find this link from IBM:
LO67255: MANAGED BEANS ANNOTATION – @POSTCONSTRUCT AND @PREDESTROY IS NOT WORKING AS EXPECTED.
http://www-01.ibm.com/support/docview.wss?crawler=1&uid=swg1LO67255
…but I do not have access to get to that article, so am not sure if the outcome is…it doesn’t work.

I have a very simple test class to demonstrate, I imported some redundant libs at top, because of last post found here: https://community.jboss.org/thread/179819 but do not have access to javax.enterprise.* in XPages.

I set the “recycling” in the DB XPage properties “Application Timeout” to 1 for testing purposes. With a simple page calling (see below)…if you wait 1 min, you can see the constructor firing, but the @PreDestroy and PostConstruct never get called.

For any comments or suggestions…thanks in advance.

Nick

import javax.annotation.*;
import java.util.Date;
import javax.annotation.PreDestroy;

import javax.faces.context.*;
import javax.faces.lifecycle.*;


public class Junk {

    public Junk(){
        System.out.println("Junk.constructor()");
    }


    @PostConstruct
    public void afterOpen(){
        System.out.println("Junk.afterOpen() Resource after open...");
    }

    /**
     * 
     * @return
     */
    public String getJunkDate(){
        String res = "";
        Date d = new Date();
        try{

            System.out.println("Junk.getJunkDate()==e");

            res = d.toLocaleString();

        }catch(Exception e){
            e.printStackTrace();
        }
        return res;
    }


    @PreDestroy
    public void destroy(){
        System.out.println("Junk.destroy()...!");
    }

    public void finalize(){
        System.out.println("Junk.finalize()...!");
    }


}

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">

    <xp:panel id="panel1">
        <xp:button value="Label" id="button1">
            <xp:eventHandler event="onclick" submit="true"
                refreshMode="partial" refreshId="panel1">
            </xp:eventHandler>
        </xp:button>
        <xp:br></xp:br>
        <xp:text escape="true" id="computedField1" value="#{javascript:Junk.junkDate}">
        </xp:text></xp:panel>
</xp:view>
  • 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-01T14:54:09+00:00Added an answer on June 1, 2026 at 2:54 pm

    There are three types of JSF listener artifacts that provide an opportunity to manually clean up objects stored in scope (including managed beans):

    1. FacesContextListener: its beforeContextReleased() method is the
      absolute last call before any request terminates, so this is an
      ideal place to clean up the requestScope.
    2. SessionListener: its
      sessionDestroyed() method provides a chance to clean up the
      sessionScope.
    3. ApplicationListener: its applicationDestroyed()
      method provides a chance to clean up the applicationScope.

    An ApplicationListener must be defined in an OSGi XSP Library; the first two can be defined either in a library or local to a specific NSF.

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

Sidebar

Related Questions

Summary: Does anyone know what the minimum we have to do is to get
Does anyone know where to find a summary table or cheatsheet for the Linux
Summary of my question: Does NSURLConnection retain its delegate? Detailed question and scenario: I
Does anyone know of a way to inject rows into a Silverlight DataGrid? I
Does anyone know an API or other method that I could generate a short
Has anyone ever seen this and does anyone know how to fix it ...
Help Perlers! Does anyone know a simple insert code here approach would bring code
Does anyone know of a function that can create an lm object given a
Summary The Faces Config Editor in Eclipse does not open when editing faces-config.xml. This
/// <summary> /// This method does something... /// </summary> public void DoSomething() { //

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.