I want to call a servlet everytime Tomcat boots up. I have made the necessary entries in the web.xml file of my web-app. But the servlet is not getting invoked.
<servlet> <servlet-name>DaemonServlet</servlet-name> <servlet-class>com.kalzoom.DaemonServlet</servlet-class> <load-on-startup>5</load-on-startup> </servlet> The class file is present in the directory.
Your servlet loads after 4 others before it. Is there any impact if there is a skip in the sequence ?
Originally posted by Kedar Dravid: I want to call a servlet everytime Tomcat boots up. I have made the necessary entries in the web.xml file of my web-app. But the servlet is not getting invoked.
<servlet> <servlet-name>DaemonServlet</servlet-name> <servlet-class>com.kalzoom.DaemonServlet</servlet-class> <load-on-startup>5</load-on-startup> </servlet> The class file is present in the directory.
I don't think a skip in the sequence would cause a problem, but you will have a problem if the sequence is duplicated. Does another servlet start at sequence 5 in your web.xml?
Mike Cronin Data On Call [ April 24, 2005: Message edited by: Mike Cronin ]
Originally posted by Kedar Dravid: I want to call a servlet everytime Tomcat boots up. I have made the necessary entries in the web.xml file of my web-app. But the servlet is not getting invoked.
<servlet> <servlet-name>DaemonServlet</servlet-name> <servlet-class>com.kalzoom.DaemonServlet</servlet-class> <load-on-startup>5</load-on-startup> </servlet> The class file is present in the directory.
If I understand the problem correctly, you want a specific servlet to run when you simply run tomcat and go to your webapp through your browser? If so, you could do this by using a servlet mapping in your web.xml file. If you are using a welcome-file-list element, then set the url-pattern in the mapping to whatever you've set your index to.
I have tried using the ServletContextListener. But now I am getting the following error: Element type "listener" must be declared. This is the entry in my web-app's web.xml file: The necessary class file is in the appropriate directory.
Originally posted by Kedar Dravid: I have tried using the ServletContextListener. But now I am getting the following error: Element type "listener" must be declared. This is the entry in my web-app's web.xml file: The necessary class file is in the appropriate directory.
Did you bring your web.xml file over from an older version? Tomcat 4.1 supports the servlet 2.3 spec. You may just need to update the DTD clause at the top of your deployment descriptor.
This is the DTD clause at the top of my web.xml: <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
I changed it to: <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/j2ee/dtds/web-app_2.3.dtd">
I have a copy of 4.1.24 on my machine. I copied the top of the web.xml file that ships in the ROOT webapps. It's a little different that what you've got. See if this works