title: Liquibase: How to execute Servlet Listener before EntityManager construction
body: <p>I manage to issue a <strong>Liquibase Update</strong> as described in <a href="http://www.liquibase.org/manual/servlet_listener" rel="nofollow noreferrer">Liquibase Servlet Listener</a>.</p>
  
  <pre><code>&lt;listener&gt;
      &lt;listener-class&gt;liquibase.servlet.LiquibaseServletListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  </code></pre>
  
  <p>This effectively executes my Changelog.  </p>
  
  <p>However, this happens <em>after</em> the setup of the EntityManager.  Obviously, this is too late if I want my Persistence provider to validate the database schema:</p>
  
  <pre><code>   &lt;property name="hibernate.hbm2ddl.auto" value="validate"/&gt;
  </code></pre>
  
  <p>... the tables simply do not exist yet.</p>
  
  <p>Is there a way I can make Liquibase to Update the database schema, <em>before</em> the EntityManager is initialized?</p>
  
  <p>PS:AppServer is JBoss6</p>
  
  <p><strong>=========================[ UPDATE ]===========================</strong></p>
  
  <p>Based on the brief discussion with Nathan below, I may have to rephrase the question as follows:</p>
  
  <blockquote>
    <p><em>Does anybody know a code hook in the JBoss startup sequence <strong>before</strong> the
    initialization of the EntityManager?</em></p>
  </blockquote>
  
  <p>If that exists, I can move the Liquibase update logic to that place? </p>