question about on load start servlet in TOMCAT

J

jojo

hi all,

I have an application run on TOMCAT AS. one of my servets is set up as
on load start. It works fine when it is deployed. but after like 10
hours, the servlet will be down and I have to reload my application to
start it up. do you know what's the problem? thanks
 
I

isitmeorthey

as far as i know you don't have any control about when gc unloads your
servlet...
By the way, it will be reload when a request is made... doesn't it ?
 
J

jojo

yes I can. but there's no request for this servlet within the program
except for the on load start up.
 
I

isitmeorthey

so, why do you need the servlet loaded, if no request is made to it ?
If it's not called within your program there's no need to it to be
loaded. On the other hand, If a request ( via url ) is made it will be
reloaded..

....am i missing something ?
 
J

jojo

actually it's a db initial stuff, kind of connection pool. other part
of the program need to get an instance from it every time when trying
to access to the database. so i made it load automatically and every
time the other DAO part get an instance from it and make the
connection.
 
A

Adam Maass

jojo said:
actually it's a db initial stuff, kind of connection pool. other part
of the program need to get an instance from it every time when trying
to access to the database. so i made it load automatically and every
time the other DAO part get an instance from it and make the
connection.

What you want is a ServletContextListener for this task instead of a
Servlet.


-- Adam Maass
 
R

Raymond DeCampo

jojo said:
actually it's a db initial stuff, kind of connection pool. other part
of the program need to get an instance from it every time when trying
to access to the database. so i made it load automatically and every
time the other DAO part get an instance from it and make the
connection.

Why are you implementing a connection pool when application servers
(including tomcat) will do that for you? Look into configuring a JNDI
DataSource for tomcat.

HTH,
Ray
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,588
Members
45,094
Latest member
PollyBlau4

Latest Threads

Top