title: Web service's PostConstruct called before servlet context listener's contextInitialized
body: <p>I need to migrate a web service application from Tomcat 6 (using JDK 1.5) to Tomcat 7 (using JDK 1.6) (actually testing on 7.0.27). The JAX-WS framework is Metro 2.1.</p>
  
  <p>I'm using two ServletContextListeners:</p>
  
  <ol>
  <li><p>"WebAppListener" : to initialize the application (configuration, setup of database connections...).</p></li>
  <li><p>"com.sun.xml.ws.transport.http.servlet.WSServletContextListener": the Metro listener that creates the web services. </p></li>
  </ol>
  
  <p>The order is important, because I need my web app fully initialized before the @PostConstruct method is called on my web service. </p>
  
  <p>In Tomcat 6, this works marvelously:</p>
  
  <pre><code>INFO: Starting Servlet Engine: Apache Tomcat/6.0.36
  mars 16, 2013 5:13:13 PM org.apache.catalina.startup.HostConfig deployWAR
  INFO: Deploying web application archive WSWebApp.war
  ************************ IN WebAppListener.contextInitialized ***********************
  ************************ IN WSMyWebService.postConstruct ****************************
  </code></pre>
  
  <p>Exactly the same war however in Tomcat 7:</p>
  
  <pre><code>mars 16, 2013 6:45:24 PM org.apache.catalina.startup.HostConfig deployWAR
  INFO: Deploying web application archive C:\home\tomcat\webapps\WSWebApp.war
  ************************ IN WSMyWebService.postConstruct ****************************
  ************************ IN WebAppListener.contextInitialized ***********************
  </code></pre>
  
  <p>I thought that the order in which the listener's are called is the order in which they appear in the web.xml?</p>
  
  <p>Why this order has been changed in Tomcat 7? But more importantly: What do I need to do to get the "Tomcat6" order back?</p>
  
  <p>Thanks.</p>