title: Unable to read property file on the application web server
body: <p>I was able to run the code in my local liberty websphere application server but when I generated a War then deploy it into websphere server I was not able to get the property file working.</p>
  
  <p>I believe the error is in the build.xml where the path generated is wrong so the property file is not read. I am using ant build</p>
  
  <p>Below is my build.xml (the property file name is DBInfo.properties)</p>
  
  <pre><code>&lt;!DOCTYPE xml&gt;
  &lt;project name="WS" basedir="." default="build" &gt;
    &lt;property name="src.dir" value ="src" /&gt;
    &lt;property name="web.dir" value ="build"/&gt;
    &lt;property name="build.dir" value="${web.dir}/classes" /&gt;
    &lt;property name="webcontent" location = "WebContent" /&gt;
  
    &lt;path id="lib"&gt;
      &lt;fileset dir="${web.dir}/WEB-INF/lib "&gt;
        &lt;include name="**/*.jar" /&gt;
      &lt;/fileset&gt;
      &lt;pathelement path="${build.dir}"/&gt;
    &lt;/path&gt;
  
    &lt;target name="init" &gt;
      &lt;copy toDir="${web.dir}" &gt;
        &lt;fileset file="${webcontent}/WEB-INF"&gt;
          &lt;include name="**" /&gt;
        &lt;/fileset&gt;
      &lt;/copy&gt;
    &lt;/target&gt;
  
    &lt;target name="build"&gt;
      &lt;mkdir dir="${build.dir} /&gt;
      &lt;javac includeantruntime="false" destdir="${build.dir}" source="1.8" target="1.8"&gt;
        &lt;src path="${src.dir}"/&gt;
        &lt;classpath refid ="lib"/&gt;
      &lt;/javac&gt;
      &lt;copy file="${src.dir}/DBInfo.properties" tofile="${web.dir}/classes/DBinfo.properties" overwrite="true" /&gt;
    &lt;/target&gt;
  
    &lt;target name="war" depends="build" &gt;
      &lt;war destfile="WS.war" webxml="${web.dir}/WEB-INF/web.xml" &gt;
        &lt;fileset dir= "${web.dir}" &gt;
          &lt;include name = "**/*.*"/&gt;
          &lt;exclude name ="**/${build.dir}/**" /&gt;
        &lt;/fileset&gt;
  
        &lt;class dir="${build.dir}" /&gt;
      &lt;/war&gt;
    &lt;/target&gt;
  </code></pre>
  
  <p>Below is the class which it uses the property file. It works on local server but when deploy the war it wasnt able to find it.</p>
  
  <pre><code>public class ConnectionManager {
  ...definable attribute
  public static Connection getConnection() {
      Properties props = new Properties();
      Connection con = null;
  
      try {
          InputStream path = ConnectionManager.class.getClassLoader().getResourceAsStream("DBInfo.properties");
          props.load(path);
  ...
  </code></pre>
  
  <p>And the file hierarchy looks like this<br>
  After build</p>
  
  <pre><code>WS
  |-java resources
  |      |-src
  |      |-DBInfo.properties
  |-Libraries
  |-build
  |   |-classes
  |   |    |-com ..
  |   |    |-DBInfo.properties
  |   |-css
  |   |-META-INF
  |   |-WEB-INF
  |-WebContent
  </code></pre>
  
  <p>Does anyone know why am I not able to get the property file after I generated war and deployed on the server? (Websphere)</p>