title: Spring - how to bootstrap web app to previously created ApplicationContext
body: <p>I have an application that heavily uses spring and packaged as <strong>.sar</strong> archive.</p>
  
  <p>Spring context created in managed bean on application deploy: </p>
  
  <pre><code>AbstractRefreshableApplicationContext springContext = new ClassPathXmlApplicationContext(spring.xml);
  </code></pre>
  
  <p>Now i need to add web functionality to this app, so i repack it as <strong>.ear</strong> and embed <strong>.war</strong> into it. </p>
  
  <p>some servlet registered in <code>web.xml</code>:</p>
  
  <pre><code>&lt;servlet&gt;
      &lt;servlet-name&gt;myServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;me.myself.MyServlet&lt;/servlet-class&gt;
    &lt;/servlet&gt; 
  </code></pre>
  
  <p>How do i autowire beans from springContext into <code>MyServlet</code>? </p>