title: classLoader.getResource() works in Eclipse but returns null when deployed
body: <p>I have an issue when I create a executable jar for my application where I'm unable to read any file located in the resource folder.
  The resource files are located under : src > main > resources.</p>
  
  <p>I have a .xml config file and the log4j.properties file there.</p>
  
  <p>When I run the application from within Eclipse everything works fine ( xml is read out and log file is created) but when I deploy it as an executable jar then suddenly no log file is written anymore and classLoader.getResource( xmlFile) returns null.</p>
  
  <p>Any idea how to solve this?</p>
  
  <p>This is piece of code I use:
  The parameter xmlFile is just the filename such as  'readMe.xml'</p>
  
  <pre><code>private Document xmlDocument (String xmlFile) throws ParserConfigurationException, SAXException, IOException{
      // return null if the file is not an xml file
      System.out.println(" - xmlFile  : " + xmlFile);
      if(! xmlFile.substring(xmlFile.lastIndexOf(".") + 1).toLowerCase().equals("xml")  ){
          return null;
      }
  
      //Get Document Builder
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      DocumentBuilder builder = factory.newDocumentBuilder();
  
      //Build Document
      ClassLoader classLoader = getClass().getClassLoader();
  
      URL res = classLoader.getResource( xmlFile);
      System.out.println(" - res : " + res);
  
      File file = new File( classLoader.getResource(  xmlFile).getFile() );
      if (file == null){
          System.out.println(" - xmlDocument - OUT");
          return null;
      }
  
      Document document = builder.parse(new File(classLoader.getResource(xmlFile).getFile()));
      //Normalise the XML Structure; 
      System.out.println(" - xmlDocument 5 - before normalizing document");
      document.getDocumentElement().normalize();
  
      return document;
  }
  </code></pre>