title: Acces to files outside WEB-INF
body: <p>I'm going to use <a href="https://web3j.io" rel="nofollow noreferrer">web3j</a> library inside servlet on <a href="http://tomcat.apache.org/" rel="nofollow noreferrer">Tomcat8</a> web-server on Linux server (Ubuntu 16.04). </p>
  
  <p>I need to read the file from the servlet. The code in servlet is: </p>
  
  <pre><code>    Credentials credentials = null;
      String password = "secretPassword";
      String pathToWalletFile = "/home/ubuntu/.ethereum/testnet/keystore/UTC--2017-06-18T03-11-13.235052023Z--6c992fb9531c9285ca9aba80c32a63074b0acd00";
      File file = new File(pathToWalletFile);
  
      try {
          credentials = WalletUtils.loadCredentials(
                  password,
                  file
          );
      } catch (CipherException e) {
          e.printStackTrace();
      }
  </code></pre>
  
  <p>the file has permissions: 644 (-rw-r--r--) Tomcat8 installed with default settings using 'sudo apt install tomcat8' on Ubuntu 16.04 (user: tomcat8) </p>
  
  <p>If I call servlet I get the following error: </p>
  
  <pre><code>HTTP Status 500 - /home/ubuntu/.ethereum/testnet/keystore/UTC--2017-06-18T03-11-13.235052023Z--6c992fb9531c9285ca9aba80c32a63074b0acd00 (Permission denied)
  
  type Exception report
  
  message /home/ubuntu/.ethereum/testnet/keystore/UTC--2017-06-18T03-11-13.235052023Z--6c992fb9531c9285ca9aba80c32a63074b0acd00 (Permission denied)
  
  description The server encountered an internal error that prevented it from fulfilling this request.
  
  exception
  
  java.io.FileNotFoundException: /home/ubuntu/.ethereum/testnet/keystore/UTC--2017-06-18T03-11-13.235052023Z--6c992fb9531c9285ca9aba80c32a63074b0acd00 (Permission denied)
  java.io.FileInputStream.open0(Native Method)
  java.io.FileInputStream.open(FileInputStream.java:195)
  java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:138)
  com.fasterxml.jackson.core.JsonFactory.createParser(JsonFactory.java:756)
  com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2740)
  org.web3j.crypto.WalletUtils.loadCredentials(WalletUtils.java:76)
  net.cryptonomica.tomcatweb3j.TestServlet.doGet(TestServlet.java:75)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  
  note The full stack trace of the root cause is available in the Apache Tomcat/8.0.32 (Ubuntu) logs.
  
  Apache Tomcat/8.0.32 (Ubuntu)
  </code></pre>
  
  <p>If I put the file inside WEB-INF, it works. How to allow access to files outside WEB-INF in tomcat (or in jetty)? </p>
  
  <hr>
  
  <p>UPD: 
  User tomcat8 can read /home/ubuntu/.ethereum/ , but can not read /home/ubuntu/.ethereum/testnet/ directory </p>
  
  <pre><code>$ sudo -u tomcat8 ls /home/ubuntu/.ethereum/testnet/ 
  </code></pre>
  
  <p>returns:</p>
  
  <pre><code>ls: cannot access '/home/ubuntu/.ethereum/testnet/': Permission denied 
  </code></pre>
  
  <p>even if I add 'tomcat8' user to 'ubuntu' group </p>
  
  <pre><code>$members ubuntu 
  </code></pre>
  
  <p>now returns: </p>
  
  <pre><code>ubuntu tomcat8
  </code></pre>
  
  <p>and </p>
  
  <pre><code>$ ls -l /home/ubuntu/.ethereum/testnet/ 
  </code></pre>
  
  <p>returns: </p>
  
  <pre><code>total 8 
  drwxr--r-- 5 ubuntu ubuntu 4096 Jun 17 17:33 geth 
  srw------- 1 ubuntu ubuntu 0 Jun 18 14:08 geth.ipc 
  drwxr--r-- 2 ubuntu ubuntu 4096 Jun 18 03:11 keystore 
  </code></pre>
  
  <p>But tomcat8 still don't have read access to /home/ubuntu/.ethereum/testnet/ </p>
  
  <p>Moving file to another directory (where user 'tomcat8' has access) solves problem. But I still not understand where the problem is. In general I'd like to have read access to file /home/ubuntu/.ethereum/testnet/  from servlets</p>