You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Cato, Christopher" <cc...@rational.com> on 2002/07/08 16:14:15 UTC

LoadOnStartup woes

I have a servlet that checks and distributes email. I need it to run on
startup. So I configure tomcat to run it on startup. The servlet starts a
thread, does it's thing and then sleeps again. Now, I marked the servlet to
run as number 99 (effectively last i hope) in the LoadOnStartup entry.

Problem is, tomcat never gets to start the http listener as the thread in my
servlet obviously puts it all to sleep before tomcat reaches that part. How
can I avoid this and still have the servlet do its thing?

/Christopher

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: LoadOnStartup woes

Posted by Mark O'Driscoll <ma...@eircom.net>.
99 means that it is the last of the loadonstartups to run, you hope.

Get your servlet to create its own thread rather than sleeping the current
one and all should be OK
----- Original Message -----
From: "Cato, Christopher" <cc...@rational.com>
To: <to...@jakarta.apache.org>
Sent: Monday, July 08, 2002 3:14 PM
Subject: LoadOnStartup woes


> I have a servlet that checks and distributes email. I need it to run on
> startup. So I configure tomcat to run it on startup. The servlet starts a
> thread, does it's thing and then sleeps again. Now, I marked the servlet
to
> run as number 99 (effectively last i hope) in the LoadOnStartup entry.
>
> Problem is, tomcat never gets to start the http listener as the thread in
my
> servlet obviously puts it all to sleep before tomcat reaches that part.
How
> can I avoid this and still have the servlet do its thing?
>
> /Christopher
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: LoadOnStartup woes

Posted by Lance Smith <ls...@emergent-netsolutions.com>.
Christopher,
The init method of the servlet must return for Tomcat to continue and
initialize the context. Since Tomcat holds the reference to the servlet I
think it is safe just to go ahead and return so long as you're thread is
self sustaining. That way Tomcat can call the destroy method on you're
servlet and you can shutdown the thread, anytime Tomcat needs to restart
you're context.
Lance

-----Original Message-----
From: Cato, Christopher [mailto:ccato@rational.com]
Sent: Monday, July 08, 2002 9:14 AM
To: 'tomcat-user@jakarta.apache.org'
Subject: LoadOnStartup woes


I have a servlet that checks and distributes email. I need it to run on
startup. So I configure tomcat to run it on startup. The servlet starts a
thread, does it's thing and then sleeps again. Now, I marked the servlet to
run as number 99 (effectively last i hope) in the LoadOnStartup entry.

Problem is, tomcat never gets to start the http listener as the thread in my
servlet obviously puts it all to sleep before tomcat reaches that part. How
can I avoid this and still have the servlet do its thing?

/Christopher

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>