Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@www.apache.org Received: (qmail 86581 invoked from network); 8 Mar 2004 17:43:09 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 8 Mar 2004 17:43:09 -0000 Received: (qmail 86429 invoked by uid 500); 8 Mar 2004 17:42:56 -0000 Delivered-To: apmail-jakarta-tomcat-dev-archive@jakarta.apache.org Received: (qmail 86401 invoked by uid 500); 8 Mar 2004 17:42:55 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Developers List" Reply-To: "Tomcat Developers List" Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 86388 invoked from network); 8 Mar 2004 17:42:55 -0000 Received: from unknown (HELO presage1.presage-designs.com) (66.98.172.60) by daedalus.apache.org with SMTP; 8 Mar 2004 17:42:55 -0000 Received: from cpe0006259cb9a5-cm014250032877.cpe.net.cable.rogers.com ([24.156.47.136] helo=trilemma) by presage1.presage-designs.com with smtp (Exim 4.24) id 1B0OmH-0001bg-JM for tomcat-dev@jakarta.apache.org; Mon, 08 Mar 2004 12:42:57 -0500 Message-ID: <00d801c40534$e5607a40$01000001@trilemma> From: "Michael Prescott" To: Subject: Behaviour of load-on-startup=0 Date: Mon, 8 Mar 2004 12:43:39 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - presage1.presage-designs.com X-AntiAbuse: Original Domain - jakarta.apache.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - ingenura.com X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N I stumbled on what I think is a small difference in Tomcat's behaviour from the Servlet spec. Looking at the code, it seems to affect both Tomcat 4 and 5. In short, the servlet specs (2.3 and 2.4) says that a servlet with value set to 0 should load before those with values of 1 or higher, but Tomcat loads 1+ first, and 0 last. "The load-on-startup element indicates that this servlet should be loaded (instantiated and have its init() called) on the startup of the web application. The optional contents of these element must be an integer indicating the order in which the servlet should be loaded. If the value is a negative integer, or the element is not present, the container is free to load the servlet whenever it chooses. If the value is a positive integer or 0, the container must load and initialize the servlet as the application is deployed. The container must guarantee that servlets marked with lower integers are loaded before servlets marked with higher integers. The container may choose the order of loading of servlets with the same load-on-start-up value." Here's the first part of loadOnStartup(Container[]). This code is identical in Tomcat 4.x (StandardContext.java:3398) and 5.x (StandardContext.java:3930). public void loadOnStartup(Container children[]) { // Collect "load on startup" servlets that need to be initialized TreeMap map = new TreeMap(); for (int i = 0; i < children.length; i++) { Wrapper wrapper = (Wrapper) children[i]; int loadOnStartup = wrapper.getLoadOnStartup(); if (loadOnStartup < 0) continue; if (loadOnStartup == 0) // Arbitrarily put them last loadOnStartup = Integer.MAX_VALUE; Integer key = new Integer(loadOnStartup); ArrayList list = (ArrayList) map.get(key); if (list == null) { list = new ArrayList(); map.put(key, list); } list.add(wrapper); } ... It appears the problem would be solved by deleting the lines that read: if (loadOnStartup == 0) // Arbitrarily put them last loadOnStartup = Integer.MAX_VALUE; Michael -- Michael Prescott Ingenura Inc. michael.prescott@ingenura.com (416) 686-8576 PGP Public Key: http://www.ingenura.com/keys/MichaelPrescott.asc --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org