title: Java Dynamic Web Service can't find file in project directory
body: <p>I created a Dynamic Web Service project in Eclipse and it runs on Apache Tomcat just fine.  The problem is, I want to read the contents of a file, but the web app can't find it.  The file is in  <code>Database/Books.json</code>, as shown below:</p>
  <p><a href="https://i.stack.imgur.com/sLYjv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sLYjv.png" alt="enter image description here" /></a></p>
  <p>I am attempting to access this file by invoking the following method with the value <code>Database/Books.json</code> as the parameter argument:</p>
  <pre class="lang-java prettyprint-override"><code>    /**
       * A utility method for reading the data stored in a json file.
       * 
       * @param filePath path to the desired database table 
       * @return the contents of the desired table
       * @throws IOException occurs when the desired file is not found
       */
      public static String readFile(String filePath) throws IOException {
          
          Path fileName = Path.of(filePath);
          String content = Files.readString(fileName);
          
          return content;
      }
  </code></pre>
  <p>But it throws a <code>NoSuchFileException</code>:</p>
  <pre><code>INFO: Server startup in 1778 ms
  java.nio.file.NoSuchFileException: Database/Books.json
      at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
      at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
      at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
      at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
      at java.base/java.nio.file.Files.newByteChannel(Files.java:375)
      at java.base/java.nio.file.Files.newByteChannel(Files.java:426)
      at java.base/java.nio.file.Files.readAllBytes(Files.java:3272)
      at java.base/java.nio.file.Files.readString(Files.java:3350)
      at java.base/java.nio.file.Files.readString(Files.java:3309)
      at com.ebook.dal.DBHelper.readFile(DBHelper.java:56)
      at com.ebook.dal.BookDAO.getAllBooks(BookDAO.java:23)
      at com.ebook.resources.EmployeeResource.getBooks(EmployeeResource.java:32)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:564)
      at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)
      at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124)
      at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167)
      at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:219)
      at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:79)
      at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:469)
      at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:391)
      at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:80)
      at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:253)
      at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
      at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:244)
      at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265)
      at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:232)
      at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:680)
      at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:392)
      at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)
      at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:365)
      at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:318)
      at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:492)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:165)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:1025)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1201)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:654)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:317)
      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.base/java.lang.Thread.run(Thread.java:832)
  Oct 04, 2020 11:06:04 PM org.apache.catalina.core.StandardContext reload
  INFO: Reloading Context with name [/BookStoreWebService] has started
  Oct 04, 2020 11:06:04 PM org.apache.catalina.startup.TldConfig execute
  INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
  Oct 04, 2020 11:06:05 PM org.apache.catalina.core.StandardContext reload
  INFO: Reloading Context with name [/BookStoreWebService] is completed
  </code></pre>
  <p>How can I locate this file?</p>