开发者

Is there a way to make Tomcat start an app up as soon as the WAR has been deployed?

My app has a bit of expe开发者_运维问答nsive setup to do when it first starts up. It appears that as soon as I copy the WAR file in webapps, the log file says "Deploying web application archive Navaid.jar", but it doesn't actually run anything until I hit the URL. I'd rather than have the first person to hit the url endure the wait time for this start up. Is there an "onDeploy" method I could use or something to do that processing, or should I just have ant copy the file, wait a few seconds, and then wget the url?


Implement a class with the ServletContextListener interface, then declare it as a listener in your web.xml:

<listener>
  <listener-class> ...your class here... </listener-class>
</listener>

Your class will get called on startup (& on shutdown).


You can specify a couple of Servlets to load on startup in your web.xml file. They can then call various parts of your app to make sure they are primed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜