Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@jakarta.apache.org Received: (qmail 70901 invoked by uid 500); 2 Oct 2001 23:57:03 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: tomcat-user@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 70889 invoked from network); 2 Oct 2001 23:57:02 -0000 From: "James Turner" To: Subject: RE: Where to put ServletContextListener? Date: Tue, 2 Oct 2001 19:57:30 -0400 Message-ID: <009201c14b9d$ffd803a0$0a01a8c0@JAMES> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2616 Importance: Normal In-Reply-To: <20011002161155.A5138-100000@localhost> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Thanks for the info, Sir. James > -----Original Message----- > From: craigmcc@h00608cebfd77.ne.mediaone.net > [mailto:craigmcc@h00608cebfd77.ne.mediaone.net] On Behalf Of > Craig R. McClanahan > Sent: Tuesday, October 02, 2001 7:15 PM > To: tomcat-user@jakarta.apache.org > Subject: Re: Where to put ServletContextListener? > > > > > On Tue, 2 Oct 2001, James Turner wrote: > > > Date: Tue, 2 Oct 2001 17:52:59 -0400 > > From: James Turner > > Reply-To: tomcat-user@jakarta.apache.org > > To: tomcat-user@jakarta.apache.org > > Subject: Where to put ServletContextListener? > > > > I'm trying to use a ServletContextListener to initialize Turbine > > standalone for my application. Here's the class: > > > > package com.bfg.services; > > import org.apache.turbine.util.TurbineConfig; > > > > public class BfgListener implements > > javax.servlet.ServletContextListener > > { > > public void > contextDestroyed(javax.servlet.ServletContextEvent sce) > > { > > } > > > > public void contextInitialized(javax.servlet.ServletContextEvent > > sce) { > > TurbineConfig tc = new > > TurbineConfig("/","TurbineResources.properties"); > > tc.init(); > > > > } > > } > > > > Because ServletContextListener is a standard part of the > Servlet API, your corresponding class goes inside your webapp > (in /WEB-INF/classes or /WEB-INF/lib), just like servlets and > bean classes do. > > You declare your listener in the /WEB-INF/web.xml file, like this: > > > com.bfg.services.BfgListener > > > The "examples" web app that comes with Tomcat 4 declares > several listeners in exactly this way -- take a look at the > web.xml file there to get the idea. > > > Here's the server.xml excerpt: > > > reloadable="true"> > > > > > > I've tried putting the class in the jar with the rest of the bfg > > classes, in a jar in the tomcat lib directory, in the > tomcat classes > > directory, in the webapp lib and classes directory, and I still get > > the same error on startup: > > > > Catalina.start: java.lang.ClassNotFoundException: > > com.bfg.services.BfgListener > > java.lang.ClassNotFoundException: com.bfg.services.BfgListener > > > > This is for internal-to-Tomcat listeners that operate > "inside" the container, rather than as part of your > application. You don't need to worry about this at all. > > > Where does it need to live? I've seen the question asked on this > > list, but not the answer. > > > > Listeners (and Filters, if you use them) go in your web app, > just like other application classes, and they are configured > in /WEB-INF/web.xml. > > > James > > > > > > Craig McClanahan > > >