Is there a way to enforce a deployment order in tomcat6?

From the Tomcat Wiki – What order do webapps start (or How can I change startup order)?

There is no expected startup order. Neither the Servlet spec nor
Tomcat define one. You can’t rely on the apps starting in any
particular order.

Tomcat has never supported specifying load order of webapps. There are other containers like JBoss that do, but Tomcat never has. Any apparent behavior that looks like load ordering via the alphabetical order of the names of the web apps is coincidental and not guaranteed to work in all cases.

What you are probably thinking of is the <load-on-startup/> element if the web.xml that specifies order of loading servlets.

That said there is an elegant solution using a service discovery protocol.

One solution is to use something like ZeroConf and register your services when they start up, and then have the dependent apps look for when these services come available and have them connect and do what ever they need to do when the service is ready. This is how I have been handling multiple dependent services for years now. I have Python, Java and Erlang services all discovering each other via ZeroConf seemlessly.

Leave a Comment