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 603391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:55:33+00:00 2026-05-13T16:55:33+00:00

For a web application I make use of JSF 1.2 and Facelets. The problem

  • 0

For a web application I make use of JSF 1.2 and Facelets.

The problem is that we now do the initialisation via a singleton pattern and that takes about 5-15 seconds because it read in data files (we are not using a database). This happens when the first user browses to the corresponding web page (the 2nd and other users don’t have this delay).

I would like to have this singleton initialised right after deployment. How can I do this? I’ve tried to add an application bean but it does not get called. I’ve also tried to add a servlet as followings:

  <servlet>
    <description>MyApplicationContextListener Servlet</description>
    <display-name>MyApplicationContextListener Servlet</display-name>
    <servlet-name>MyApplicationContextListener</servlet-name>
    <servlet-class>mydomain.beans.MyApplicationContextListener</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <listener>
    <listener-class>mydomain.beans.MyApplicationContextListener</listener-class>
  </listener>

with the following code:

package mydomain.beans;
import javax.servlet.ServletContextEvent;

public class MyApplicationContextListener {


    public void contextInitialized(ServletContextEvent event) {
        System.out.println("MyApplicationContextListener.contextInitialized started");
    }

    public void contextDestroyed(ServletContextEvent event) {
        System.out.println("MyApplicationContextListener.contextInitialized stopped");
    }

}

An example including changes needed in web.xml and/or faces-config.xml would be nice!

  • 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-05-13T16:55:33+00:00Added an answer on May 13, 2026 at 4:55 pm

    How about using a ServletContextListener ? Its contextInitialized(..) method will be called at the moment the context is initialized. It’s mapped in web.xml like this:

    <listener>
        <listener-class>com.example.MyServletContextListener</listener-class>
    </listener>
    

    Also, (not sure this would work), you can configure your faces-servlet to be loaded on startup.:

    <load-on-startup>1</load-on-startup>
    

    Clarification: For the listener approach, your listener must implement the ServletContextListener:

    public class MyServletContextListener implements ServletContextListener { .. }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java EE web application that does not make use of EJBs.
I'm working on an HTML5-based web application that will make use of a local
I am working on a web application that will make extensive use of AJAX
In a JSF Facelets web application, is it possible to make a jQuery AJAX
I'm trying to use Netbeans to make a web application using facelets. I want
I have several web applications that make use of packages using WebActivator. On my
I like to get inspiration from using web applications that make good use of
I intend to make a web application that displays 3d environments that can be
My next web application project will make extensive use of Unicode. I usually use
I am developing a web application that uses JSF 1.2 for the view layer.

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.