Do you have any idea about the following error while running Tomcat ?: WebappClassLoader: Lifecycle error : CL stopped
I'm getting these while trying to context listener to run run a timer thread on start up Tomcat. Thanks In Advance, Sudarson -----Original Message----- From: Christopher K. St. John [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 30, 2002 11:23 PM To: [EMAIL PROTECTED] Subject: Re: start up class in tomcat Sudarson Roy Pratihar wrote: > > I'm using Tomcat 4.0. Can u pls tell me some more on > org.apache.catalina.Service > Yes, but only if you promise to stop using "u" for "you" and "pls" for "please". :-) Basic idea is you write your own class that implements the Service interface, drop it into a directory where Tomcat can find it [1], and add it to your server.xml along with the normal Tomcat Service [2]. But you're pretty much on your own with this approach, so I don't recommend it. Instead, try to stick as much as possible with absolutely standard parts of the servlet API (like Context Listeners) > Context Lifecycle Listener ? > There's an example in the latest (2.3) version of the servlet spec. You can download the spec at: http://java.sun.com/products/servlet/download.html There's also info in the javadocs for javax.servlet. ServletContextListener. Basic idea is that your write a class that implements the listener interface, drop it in with your servlet code, then add the appropriate registration to your web.xml. I suggest first writing a simple "hello context" listener that just prints out a message when the context is created and destroyed. Remember: any resource you grab at context startup (like threads) must be explicitly released when the context is destroyed. Contexts can get destroyed at times you might not expect, like when your webapp gets reloaded. If you don't release the threads (or database connections, or whatever), then they will gradually build up and you get a resource leak. > Pls also suggest which of the approaches you think > better. > See above. The ServletContextListener is a standard part of the servlet API, so you should stick with it if you can. Starting threads from anywhere is a bit risky (see ref. from previous message), but if you gotta do it, you gotta do it. [1] http://jakarta.apache.org/tomcat/tomcat-4.0-doc/class-loader-howto.html [2] http://jakarta.apache.org/tomcat/tomcat-4.0-doc/config/index.html -- Christopher St. John [EMAIL PROTECTED] DistribuTopia http://www.distributopia.com ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
