tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <Yoav.Shap...@mpi.com>
Subject RE: contextInitialized being called exactly twice
Date Thu, 10 Jun 2004 18:06:21 GMT

Hi
I bet it's being called once for each time the context is deployed, and
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 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
(Con
>tainerBase.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:8
0)
>         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:8
0)
>         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




This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, 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


Mime
View raw message