aspose file tools*
The moose likes Tomcat and the fly likes ContextListener starting twice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "ContextListener starting twice" Watch "ContextListener starting twice" New topic
Author

ContextListener starting twice

Allen Williams
Ranch Hand

Joined: Sep 04, 2006
Posts: 136
I have a very simple context listener that just sets a context variable at initialization. The action is here:

Note the "log.write" at the very end. In addition, the dbUtils constructor has a print statement. Here is the deployment descriptor from the web.xml (and I did a search to make sure it is the only one):

When this listener is run at initialization, here is what I get in the log file:

SEVERE: No Store configured, persistence disabled

************
dbConPoolListener::ContextInitialized
Jun 23 16:40:45: Got db name: infoisland

Initializing dbUtils with sc; sc, ds= org.apache.catalina.core.ApplicationContextFacade@ed662d null
Jun 23 16:40:45: dbUtils::initPool
Jun 23 16:40:45: dbConPoolListener::Seems to have run OK
******************

Jun 23, 2007 4:40:45 PM org.apache.catalina.session.PersistentManagerBase start
SEVERE: No Store configured, persistence disabled

************
dbConPoolListener::ContextInitialized
Jun 23 16:40:45: Got db name: infoisland

Initializing dbUtils with sc; sc, ds= org.apache.catalina.core.ApplicationContextFacade@b122a1 null
Jun 23 16:40:45: dbUtils::initPool
Jun 23 16:40:45: dbConPoolListener::Seems to have run OK
*******************

Jun 23, 2007 4:40:46 PM org.apache.coyote.http11.Http11BaseProtocol start

In other words, it looks like it is running twice. Any ideas why this would be? In my server.xml, I do have two Contexts with the same docbase. Is that what's causing this?

TIA,
anw


-------<br />Thanks & regards,<br />anw
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60080
    
  65

Well, yeah. Two contexts means two web apps.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

A typical cause for this is an app that is both configured in either server.xml or with a context fragment; and that is located in the tomcat/webapps directory (where it will be auto deployed).


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ContextListener starting twice
 
Similar Threads
JSF Example Error
Tomcat Connection pool creating too many connections, stuck in sleep mode
context variable in action servlet
In tomcat6, System.err.println or System.out.println don't seem to work
ServeltContextListener for DataSource