title: Unable to resolve datasource JNDI after web application shutdown/start in Weblogic 12c
body: <p>I have a DataSource configured in a Weblogic 12c as shown on the image below:</p>
  
  <p><a href="https://i.stack.imgur.com/E8YSB.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E8YSB.jpg" alt="Datasource"></a></p>
  
  <p>And I also have a web application on the same Weblogic server that uses this datasource:</p>
  
  <p><a href="https://i.stack.imgur.com/R0s7d.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R0s7d.jpg" alt="Web Application"></a></p>
  
  <p>Whenever I start Weblogic from the ground up everything works fine. But, after it is up, if I try to shutdown the webapplication and then start it again, I have an "javax.naming.NameNotFoundException" as shown below:</p>
  
  <p><a href="https://i.stack.imgur.com/785Ik.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/785Ik.jpg" alt="enter image description here"></a></p>
  
  <p>This is the code I am using to get the datasource:</p>
  
  <pre><code>@Bean
  public DataSource dataSource() {
      final JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
      dsLookup.setResourceRef(true);
      DataSource dataSource = dsLookup.getDataSource("jdbc/xdrstoredbds");
      return dataSource;
  } 
  </code></pre>
  
  <p>What may I be missing?</p>