Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@www.apache.org Received: (qmail 18040 invoked from network); 10 Jun 2004 18:07:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 10 Jun 2004 18:07:52 -0000 Received: (qmail 3160 invoked by uid 500); 10 Jun 2004 18:07:40 -0000 Delivered-To: apmail-jakarta-tomcat-user-archive@jakarta.apache.org Received: (qmail 3123 invoked by uid 500); 10 Jun 2004 18:07:40 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Users List" Reply-To: "Tomcat Users List" Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 3108 invoked by uid 99); 10 Jun 2004 18:07:39 -0000 Received: from [63.244.250.133] (HELO warhawk.mpi.com) (63.244.250.133) by apache.org (qpsmtpd/0.27.1) with ESMTP; Thu, 10 Jun 2004 11:07:39 -0700 Received: from lightning.mpi.com (lightning [63.244.252.11]) by warhawk.mpi.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id i5AI2n5L006884 for ; Thu, 10 Jun 2004 14:02:49 -0400 (EDT) Received: from US-VS1.corp.mpi.com (us-be2.corp.mpi.com [63.244.252.32]) by lightning.mpi.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id i5AI6l74003258 for ; Thu, 10 Jun 2004 14:07:15 -0400 (EDT) X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 Content-Class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: contextInitialized being called exactly twice Date: Thu, 10 Jun 2004 14:06:21 -0400 Message-ID: <9C5166762F311146951505C6790A9CF80229BAF8@US-VS1.corp.mpi.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: contextInitialized being called exactly twice thread-index: AcRPCGd4WJga0wgPQdygaRShNOfbJAADQj+Q From: "Shapira, Yoav" To: "Tomcat Users List" X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N H= i I bet it's being called once for each time the context is deployed, an= d the context is deployed twice because you have autoDeploy on AND an explicit context declaration in your server.xml/conf directory/WAR. Turn autoDeploy off and see what happens. (This would explain the static counter being 1: the counter is static once per classloader repository, you have two of the same context at different paths with different classloader repositories). Yoav Shapira Millennium Research Informatics >-----Original Message----- >From: Graham Smith [mailto:graham@crazysquirrel.com] >Sent: Thursday, June 10, 2004 12:32 PM >To: tomcat-user@jakarta.apache.org >Subject: contextInitialized being called exactly twice > >Hi, > >I am absolutely stumped by this problem. For some reason that I can't= >fathom the contextInitialized method on a ServletContextListener I ha= ve >in one of my web applications is being called twice. Normally this isn't >a problem since it only causes the load process to take longer but I >have recently added a new section that starts a daemon thread and it >this double call is causing two threads to be created. What is even more >bizarre is that I have tried using a static int to count the number o= f >times the method is called but it always returns one. I suspected tha= t >it therefore must be created by a different class loader but a call t= o >getClass().getClassLoader and a dump (see below) of information would= >seem to indicate that it is in fact the same class loader loading the= >class. I am using tomcat 5.0.25 on Linux with Java 1.4.2_04. I have also >performed a thread dump in order to check that it is _really_ being r= un >twice and sure enough there are two copies of my thread running (agai= n >see extract below). > >Any help would be greatly appreciated. > >Graham > >ClassLoader dump: >---------------------------------------------------- >First time it is loaded >---------------------------------------------------- >ClassLoader: WebappClassLoader > delegate: false > repositories: >----------> Parent Classloader: >StandardClassLoader > delegate: true > repositories: > file:/home/gms/dump/tomcat/shared/classes/ >----------> Parent Classloader: >StandardClassLoader > delegate: true > repositories: > file:/home/gms/dump/tomcat/common/classes/ > file:/home/gms/dump/tomcat/common/endorsed/xercesImpl.jar > file:/home/gms/dump/tomcat/common/endorsed/xmlParserAPIs.jar > file:/home/gms/dump/tomcat/common/lib/ant.jar > file:/home/gms/dump/tomcat/common/lib/commons-collections.jar > file:/home/gms/dump/tomcat/common/lib/commons-dbcp-1.1.jar > file:/home/gms/dump/tomcat/common/lib/commons-el.jar > file:/home/gms/dump/tomcat/common/lib/commons-pool-1.1.jar > file:/home/gms/dump/tomcat/common/lib/jasper-compiler.jar > file:/home/gms/dump/tomcat/common/lib/jasper-runtime.jar > file:/home/gms/dump/tomcat/common/lib/jsp-api.jar > file:/home/gms/dump/tomcat/common/lib/naming-common.jar > file:/home/gms/dump/tomcat/common/lib/naming-factory.jar > file:/home/gms/dump/tomcat/common/lib/naming-java.jar > file:/home/gms/dump/tomcat/common/lib/naming-resources.jar > file:/home/gms/dump/tomcat/common/lib/servlet-api.jar >----------> Parent Classloader: >sun.misc.Launcher$AppClassLoader@136228 > > >---------------------------------------------------- >Second time it is loaded >---------------------------------------------------- > >ClassLoader: WebappClassLoader > delegate: false > repositories: >----------> Parent Classloader: >StandardClassLoader > delegate: true > repositories: > file:/home/gms/dump/tomcat/shared/classes/ >----------> Parent Classloader: >StandardClassLoader > delegate: true > repositories: > file:/home/gms/dump/tomcat/common/classes/ > file:/home/gms/dump/tomcat/common/endorsed/xercesImpl.jar > file:/home/gms/dump/tomcat/common/endorsed/xmlParserAPIs.jar > file:/home/gms/dump/tomcat/common/lib/ant.jar > file:/home/gms/dump/tomcat/common/lib/commons-collections.jar > file:/home/gms/dump/tomcat/common/lib/commons-dbcp-1.1.jar > file:/home/gms/dump/tomcat/common/lib/commons-el.jar > file:/home/gms/dump/tomcat/common/lib/commons-pool-1.1.jar > file:/home/gms/dump/tomcat/common/lib/jasper-compiler.jar > file:/home/gms/dump/tomcat/common/lib/jasper-runtime.jar > file:/home/gms/dump/tomcat/common/lib/jsp-api.jar > file:/home/gms/dump/tomcat/common/lib/naming-common.jar > file:/home/gms/dump/tomcat/common/lib/naming-factory.jar > file:/home/gms/dump/tomcat/common/lib/naming-java.jar > file:/home/gms/dump/tomcat/common/lib/naming-resources.jar > file:/home/gms/dump/tomcat/common/lib/servlet-api.jar >----------> Parent Classloader: >sun.misc.Launcher$AppClassLoader@136228 > > > >---------------------------------------------------- >Extract of thread dump >---------------------------------------------------- > >...... > > >"ContainerBackgroundProcessor[StandardEngine[Catalina]]" daemon prio=3D= 1 >tid=3D0x0848eb98 nid=3D0x7d54 waiting on condition [4d90d000..4d90d85= 4] > at java.lang.Thread.sleep(Native Method) > at >org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.r= un (Con >tainerBase.java:1597) > at java.lang.Thread.run(Thread.java:534) > >"category statistics generator" daemon prio=3D1 tid=3D0x082e6960 nid=3D= 0x7d54 >waiting on condition [4e1de000..4e1de854] > at java.lang.Thread.sleep(Native Method) > at >com.crazysquirrel.xfly.category.CategoryStats.run(CategoryStats.java:= 73 ) > at java.lang.Thread.run(Thread.java:534) > >"directory cleaner" daemon prio=3D1 tid=3D0x0852dd30 nid=3D0x7d54 wai= ting on >condition [4e15d000..4e15d854] > at java.lang.Thread.sleep(Native Method) > at >com.crazysquirrel.xfly.web.DirectoryCleaner.run(DirectoryCleaner.java= :8 0) > at java.lang.Thread.run(Thread.java:534) > >"category statistics generator" daemon prio=3D1 tid=3D0x085072f8 nid=3D= 0x7d54 >waiting on condition [4e0dc000..4e0dc854] > at java.lang.Thread.sleep(Native Method) > at >com.crazysquirrel.xfly.category.CategoryStats.run(CategoryStats.java:= 73 ) > at java.lang.Thread.run(Thread.java:534) > >"directory cleaner" daemon prio=3D1 tid=3D0x084e7ea8 nid=3D0x7d54 wai= ting on >condition [4e05b000..4e05b854] > at java.lang.Thread.sleep(Native Method) > at >com.crazysquirrel.xfly.web.DirectoryCleaner.run(DirectoryCleaner.java= :8 0) > at java.lang.Thread.run(Thread.java:534) > >"Signal Dispatcher" daemon prio=3D1 tid=3D0x08096a50 nid=3D0x7d54 wai= ting on >condition [0..0] > >........ > >---------------------------------------------------------------------= >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org This e-mail, including any attachments, is a confidential business com= munication, and may contain information that is confidential, propriet= ary and/or privileged. This e-mail is intended only for the individua= l(s) to whom it is addressed, and may not be saved, copied, printed, d= isclosed or used by anyone else. If you are not the(an) intended reci= pient, please immediately delete this e-mail from your computer system= and notify the sender. Thank you. --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-user-help@jakarta.apache.org