Is there any mechanism, lifecycle event or callbacks, in Spring or Tomcat to notify once Tomcat server startup is completed? (I have 8 web applications and queues configured
All of the major Tomcat components implement org.apache.catalina.Lifecycle
which includes the ability to add a org.apache.catalina.LifecycleListener
. It sounds like you want the AFTER_START_EVENT
of the Host
.
You configure the listener in server.xml like this:
<Host ... >
<Listener className="your.package.KPTomcatListener"/>
<!-- Other nested elements go here -->
</Host>
The class must be packaged in a JAR and the JAR placed in Tomcat's lib directory.
In case someone wants to do it programmatically (if using embedded Tomcat for example):
Tomcat tomcat = new Tomcat();
...
tomcat.getServer().addLifecycleListener(new KPTomcatListener());
tomcat.start()