Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 16205 invoked from network); 24 Jan 2006 20:03:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 24 Jan 2006 20:03:45 -0000 Received: (qmail 87709 invoked by uid 500); 24 Jan 2006 20:03:31 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 87695 invoked by uid 500); 24 Jan 2006 20:03:31 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 87683 invoked by uid 99); 24 Jan 2006 20:03:31 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Jan 2006 12:03:31 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [216.227.215.170] (HELO chiron.lunarpages.com) (216.227.215.170) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Jan 2006 12:03:30 -0800 Received: from zammet2 by chiron.lunarpages.com with local (Exim 4.52) id 1F1UNh-0005cd-7C; Tue, 24 Jan 2006 12:03:09 -0800 Received: from 170.201.180.136 ([170.201.180.136]) (SquirrelMail authenticated user fzlists@omnytex.com) by webmail.chiron.lunarpages.com with HTTP; Tue, 24 Jan 2006 15:03:09 -0500 (EST) Message-ID: <23515.170.201.180.136.1138132989.squirrel@webmail.chiron.lunarpages.com> In-Reply-To: <200601241941.k0OJffxv013625@apps05.teamon.com> References: <200601241941.k0OJffxv013625@apps05.teamon.com> Date: Tue, 24 Jan 2006 15:03:09 -0500 (EST) Subject: Re: Do idle servlets get unloaded/reloaded? From: "Frank W. Zammetti" To: "Tomcat Users List" Cc: users@tomcat.apache.org User-Agent: SquirrelMail/1.4.4 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - chiron.lunarpages.com X-AntiAbuse: Original Domain - tomcat.apache.org X-AntiAbuse: Originator/Caller UID/GID - [32746 1232] / [47 12] X-AntiAbuse: Sender Address Domain - omnytex.com X-Source: X-Source-Args: X-Source-Dir: X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi Blair, On Tue, January 24, 2006 2:41 pm, Blair Cooper said: > I have a servlet running on Tomcat 5.5. If it sits idle for a while and > then > I hit it, the init() method gets called again. "autoDeploy" is set to > false. > Is this expected behavior? As per the servlet spec, the container can unload and reload a servlet as needed. It is an expected *potential* behavior. My own personal experience would indicate it's rare, but you have to design for it. > If this is expected, shouldn't destroy() get called at some point prior to > the init()? I would expect destroy() to get called at some point before init() does a second time, but I'm not sure if that is a guarantee of the spec. Seems like it probably would be though. > The problem I'm having is that the init() method ends up try to recreate > objects that where created by a previous call to init(). My destroy() > method > would have cleaned up the earlier instances if it had been called. I have > logging in the destroy() method so I know that it didn't get called. Implement some sort of check in init() to determine if it has fired already or not. A simple static boolean field on the servlet should do the trick. So, maybe you have: private static boolean isInitialized; Then in init(), you do: synchronized (isInitialized) { if (!isInitialized) { // Do initialization tasks. isInitialized = true; } } > Thanks, > > Blair Frank --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org