tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Graham Smith <gra...@crazysquirrel.com>
Subject contextInitialized being called exactly twice
Date Thu, 10 Jun 2004 16:31:48 GMT
Hi,

I am absolutely stumped by this problem. For some reason that I can't 
fathom the contextInitialized method on a ServletContextListener I have 
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 of 
times the method is called but it always returns one. I suspected that 
it therefore must be created by a different class loader but a call to 
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 run 
twice and sure enough there are two copies of my thread running (again 
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=1 
tid=0x0848eb98 nid=0x7d54 waiting on condition [4d90d000..4d90d854]
         at java.lang.Thread.sleep(Native Method)
         at 
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1597)
         at java.lang.Thread.run(Thread.java:534)

"category statistics generator" daemon prio=1 tid=0x082e6960 nid=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=1 tid=0x0852dd30 nid=0x7d54 waiting on 
condition [4e15d000..4e15d854]
         at java.lang.Thread.sleep(Native Method)
         at 
com.crazysquirrel.xfly.web.DirectoryCleaner.run(DirectoryCleaner.java:80)
         at java.lang.Thread.run(Thread.java:534)

"category statistics generator" daemon prio=1 tid=0x085072f8 nid=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=1 tid=0x084e7ea8 nid=0x7d54 waiting on 
condition [4e05b000..4e05b854]
         at java.lang.Thread.sleep(Native Method)
         at 
com.crazysquirrel.xfly.web.DirectoryCleaner.run(DirectoryCleaner.java:80)
         at java.lang.Thread.run(Thread.java:534)

"Signal Dispatcher" daemon prio=1 tid=0x08096a50 nid=0x7d54 waiting 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


Mime
View raw message