Advertisement

09.25.2005 at 07:20PM PDT, ID: 21573574
[x]
Attachment Details

Tomcat executes init() in load-on-startup servlet twice

Asked by blackfrancis75 in Java Programming Language, Java Servlets, New to Java Programming

Tags: servlet, tomcat, twice, init

Hi,
Ive created a 'StartupServlet' in my web app which has <load-on-startup> set so that it is initiallised when the webapp starts.
Problem is, the code is being run TWICE on startup.

Here is the code for the servlet:

public class StartupServlet extends HttpServlet {
   
    Logger log = Logger.getLogger(StartupServlet.class);
   
    public static TimerTask scheduler = null;
 
    public void init() throws ServletException {

        super.init();
       
        log.info("StartupServlet.init()");
       
        if( scheduler == null )
        {
            scheduler = new SchedulerService();
        }
       
    }
}

The strangest thing is that I can see from the logs that SchedulerService gets initialised twice !!
How can this be?  Especially since scheduler is a static member of StartupServlet!

Any info on this gratefully received.
 
Start Free Trial
 
 
[+][-]09.25.2005 at 08:08PM PDT, ID: 14956182

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.25.2005 at 08:09PM PDT, ID: 14956184

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.25.2005 at 08:18PM PDT, ID: 14956215

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.25.2005 at 08:25PM PDT, ID: 14956232

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.25.2005 at 08:46PM PDT, ID: 14956280

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.25.2005 at 08:50PM PDT, ID: 14956288

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.25.2005 at 09:09PM PDT, ID: 14956332

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09.25.2005 at 09:11PM PDT, ID: 14956337

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Java Programming Language, Java Servlets, New to Java Programming
Tags: servlet, tomcat, twice, init
Sign Up Now!
Solution Provided By: todd_farmer
Participating Experts: 3
Solution Grade: A
 
 
[+][-]09.25.2005 at 09:11PM PDT, ID: 14956338

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.25.2005 at 09:20PM PDT, ID: 14956354

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.25.2005 at 09:33PM PDT, ID: 14956402

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.25.2005 at 09:34PM PDT, ID: 14956404

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.25.2005 at 09:39PM PDT, ID: 14956422

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.25.2005 at 11:45PM PDT, ID: 14956758

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.25.2005 at 11:57PM PDT, ID: 14956790

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.26.2005 at 12:02AM PDT, ID: 14956804

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.26.2005 at 12:21AM PDT, ID: 14956887

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.26.2005 at 12:22AM PDT, ID: 14956890

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.26.2005 at 12:25AM PDT, ID: 14956903

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.26.2005 at 12:27AM PDT, ID: 14956915

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.26.2005 at 07:49AM PDT, ID: 14959139

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32