I have a function I want to execute straight after tomcat has started and loaded all its attributes successfully. I don\'t want to use ServletContextListener as this will re
You could create a startup servlet and then add that to the end of your web.xml:
<servlet>
        <servlet-name>StartupServlet</servlet-name>
        <servlet-class>com.your.package.MyStartupServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
</servlet>
public class MyStartupServlet extends HttpServlet {
    public void init(ServletConfig config) throws ServletException {
        try {
             //  Startup code here
        } catch (Exception e){
            // Log exception
        }
    }
    public java.lang.String getServletInfo() {
        return "StartupServlet";
    }
}
                                                                        I think JMX Tomcat supports can meet your requirement, even no ServletContextListener is deployed in container.
ServletContextListener.contextInitialized(..) is the method that is called after all servlets and filters have initialized for a given application.
ServletContextListeners, some of them are called before the others (logically)Update I will now assume your setup, although you didn't share it:
In that case, you have two options:
ServletContextListener after the one for spring in web.xml, thus guaranteeing it will be invoked after it