web.xml load-on-startup question

what does it do when

<load-on-startup>-1</load-on-startup> in the web.xml on a servlet

that is a negative 1

what happens when i have multiple

Servlet 1

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

Servlet 2

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

[322 byte] By [khan2265a] at [2007-11-27 5:26:04]
# 1

http://tomcat.apache.org/tomcat-4.0-doc/catalina/docs/api/org/apache/catalina/Wrapper.html

I think it's container-dependent, but for Tomcat:

getLoadOnStartup

public int getLoadOnStartup()

Return the load-on-startup order value (negative value means load on first call).

kevjavaa at 2007-7-12 14:46:34 > top of Java-index,Java Essentials,Java Programming...
# 2

load-on-startup is supposed to be supplied with a single, positive number. I think it's ignored if the number is negative, but I'm guessing there. If you had 2 servlets with the same positive load-on-startup value, same 5, it would be up to the container -- the loading order between the two would be undetermined.

Hippolytea at 2007-7-12 14:46:34 > top of Java-index,Java Essentials,Java Programming...
# 3

> what does it do when

>

> <load-on-startup>-1</load-on-startup> in the web.xml

> on a servlet

> that is a negative 1

>

>

> what happens when i have multiple

>

> Servlet 1

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

> Servlet 2

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

Are you asking whether Servlet 1 or Servlet 2 will get loaded?

In the case above, -1 indicates load at first call... so... I would say (like the first responder) whichever one gets called first.

I would assume you have no guarantees...but my experience is that first listed in web.xml gets loaded first. (so if you had two with a load-on-startup of 0 for example--I have usually seen the first in the web.xml start first)

xiarcela at 2007-7-12 14:46:34 > top of Java-index,Java Essentials,Java Programming...
# 4

According to OnJava, it's container specific, but I probably wouldn't use the negative value unless you know for certain it will be run only in containers whose behavior you are aware of:

http://www.onjava.com/pub/a/onjava/2001/04/19/tomcat.html?page=4

"The <load-on-startup> sub-element indicates the order in which each servlet should be loaded. Lower positive values are loaded first. If the value is negative or unspecified, then the container can load the servlet at anytime during startup."

kevjavaa at 2007-7-12 14:46:34 > top of Java-index,Java Essentials,Java Programming...
# 5

thanks for the replies

I am running into a issue that is really weird

so i made the servlet to load with 0 and 1 and the servlets loads on start on my local machine, however when i tried on another server, it does not load any of the servlets....any idea as to why that happens?

both env are Websphere 5.1.1

khan2265a at 2007-7-12 14:46:34 > top of Java-index,Java Essentials,Java Programming...
# 6

> thanks for the replies

>

> I am running into a issue that is really weird

>

> so i made the servlet to load with 0 and 1 and the

> servlets loads on start on my local machine, however

> when i tried on another server, it does not load any

> of the servlets....any idea as to why that happens?

>

Some sort of as of yet unidentified configuration and/or deployment problem.

cotton.ma at 2007-7-12 14:46:34 > top of Java-index,Java Essentials,Java Programming...
# 7
anyone know what configuration i should check regarding this issue?...
khan2265a at 2007-7-12 14:46:34 > top of Java-index,Java Essentials,Java Programming...
# 8
I still can't solve this issue =(
khan2265a at 2007-7-12 14:46:34 > top of Java-index,Java Essentials,Java Programming...