Search code examples
javatomcatweb.xml

How to define the correct startup order of a Java Tomcat application?


In my Java Tomcat application I setup some properties to be used in the whole application. But apparently other functions (eg Hibernate) are already starting before and need some of these properties.

The properties are initialized in the class defined in web.xml with:

<listener>
   <listener-class>com.mycode.ApplicationContextListener</listener-class
</listener>

Is there a way (in web.xml?) to define the very first function to be started when Tomcat starts the application? Or another method?

Thanks, Frank


Solution

  • You can use the XML tag "loadOnStartup" as described here, to define which class has to startup first.