title: getResourceAsStream to get a file inside the war
body: <p>I have a maven project that builds a war file with a file inside it I want to read.</p>
  
  <p>No exceptions are thrown...</p>
  
  <p><strong><em>EDIT</em></strong> Note that this is <strong>not in a servlet</strong>:</p>
  
  <pre><code>@Path("")
  @Stateless
  public class MessageRestService {
  
  //String liquibaseTenantDefinitionFile = "/WEB-INF/liquibase/db.tenant.xml";
  //String liquibaseTenantDefinitionFile = "/WEB-INF/classes/liquibase/db.tenant.xml";
  //String liquibaseTenantDefinitionFile = "WEB-INF/classes/liquibase/db.tenant.xml";
  //String liquibaseTenantDefinitionFile = "/liquibase/db.tenant.xml";
  String liquibaseTenantDefinitionFile = "liquibase/db.tenant.xml";
  
  public InputStream getTenantFile(){
      try {
          return getClass().getClassLoader()
                  .getResourceAsStream(liquibaseTenantDefinitionFile);
      } catch(Exception e){
          System.err.println(e);
          System.err.println(e.getMessage());
          e.printStackTrace();
      }
      return null;
  }
  </code></pre>
  
  <p>This file does exist in the war file:</p>
  
  <pre><code>jar -tf target/grest-0.0.1-SNAPSHOT.war | grep db.tenant.xml
  WEB-INF/classes/liquibase/db.tenant.xml
  </code></pre>
  
  <p>The method <em>always</em> returns null, I've tried all kinds of permutations: </p>
  
  <ul>
  <li>leading slashes</li>
  <li>no leading slashes</li>
  <li>different classloader getting methods</li>
  <li>WEB-INF/ no WEB-INF</li>
  <li>with and without classes</li>
  </ul>
  
  <p>I cannot figure out how to do this.  I'm using wildfly and testing with the Arquillian jboss container.</p>
  
  <p>What am I doing wrong?</p>