On 04.01.20 15:35, bphamhuu wrote:
> Hello,
>
> I have a java web application by Tomcat 9 servlet container which tries to
> read a file in /tmp folder with 777 permission on Ubuntu 18.04
>
> ls -ltr /tmp/test.txt
> -rwxrwxrwx 1 vagrant vagrant 10 Jan  3 17:03 /tmp/test.txt
>
> The java code is:
>
>     try {
>         result = FileUtils.readFileToString(new File("/tmp/test.txt"));
>     } catch (IOException ex) {
>         log.info("##### Cannot read file. Reason: " + ex.getMessage());
>     }
>
> But it always show the error
>
> ##### Cannot read file. Reason: File '/tmp/test.txt' does not exist


You're running tomcat on Ubuntu, I'm assuming you use the version from
the Debian repositories, not one that you downloaded from tomcat.apache.org.

Debian's tomcat is sandboxed. Read /usr/share/doc/tomcat9/README.Debian
(or an online version at
https://salsa.debian.org/java-team/tomcat9/blob/master/debian/README.Debian)
for more information (search for "sandboxed" to find the proper place)

Credits: I keep this under my belt since Emmanuel Bourg answered a
similar question on this list a while back.

And don't forget to reset the 777 permissions.

Olaf


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to