title: Spring Boot still requires resource-ref in web.xml
body: <p>Looking into Spring Boot right now and want to do it properly, as using Java config and ultimately without any <code>web.xml</code>. So, the tricky part is that the production environment requires a classic <code>WAR</code> file. </p>
  
  <p>Hence, I'm specified <code>WAR</code> packaging within my Maven <code>pom.xml</code>file and the main Application class extends <code>SpringBootServletInitializer</code>. </p>
  
  <p>Works just fine. Now, the tricky part is that in the production environment the <code>Datasource</code> is provisioned via <code>JNDI</code>. In a classic Spring app you would reference this dependency in the <code>web.xml</code> using a <code>resource-ref</code> as follows:</p>
  
  <pre><code> &lt;resource-ref&gt;
      &lt;res-ref-name&gt;jdbc/DefaultDB&lt;/res-ref-name&gt;
      &lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt;
  &lt;/resource-ref&gt;
  </code></pre>
  
  <p>All the research I did seems to indicate that I would be able to get rid of the <code>web.xml</code> and replacing it with a respective <code>context.xml</code> file (in META-INF folder):</p>
  
  <pre><code>   &lt;Resource name="jdbc/DefaultDB"
            auth="Container"
            type="javax.sql.DataSource"
            factory="com.sap.jpaas.service.persistence.core.JNDIDataSourceFactory"/&gt;
  </code></pre>
  
  <p>Unfortunately that doesn't work :/</p>
  
  <p>The interesting thing though is that a plain servlet3 web app works just fine that way, see [<a href="https://github.com/steinermatt/servlet3-sample]" rel="noreferrer">https://github.com/steinermatt/servlet3-sample]</a>.</p>
  
  <p>So, I'm tempted to believe that the root cause it doesn't work for a Spring Boot app is related to the Spring Boot bootstrapping process... so, really looking for any hints, suggestions on what it could be!!!</p>
  
  <p>Any help is appreciated!</p>