Hi, Thanks for this link https://salsa.debian.org/java-team/tomcat9/blob/master/debian/README.Debian. But I cannot *read* the file from /tmp (not *write* file to /tmp). The strange thing is, it can read another file from another location, e.g in /opt/:
ls -ltr /opt/rasdaman/etc/petascope.properties -rwxrwxrwx 1 rasdaman rasdaman 13095 Jan 3 16:25 /opt/rasdaman/etc/petascope.properties + java code: File tempFile = new File("/opt/rasdaman/etc/petascope.properties"); log.info("WITH FOLDER /tmp Exists: " + tempFile.exists() + ", readable: " + tempFile.canRead() + ", writable: " + tempFile.canWrite()); + with log results: WITH FOLDER /tmp Exists: true, readable: true, writable: false On Sat, 4 Jan 2020 at 15:58, Olaf Kock <tom...@olafkock.de> wrote: > > 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 > > -- *Bang Pham Huu * *-------------------------------------------------------------------------------------* *Master of Science - Research Assistant at Field Monitoring Center - 4 F, E3 BuildingViet Nam - Ha Noi National University - University of Engineering and Technology* *Email: a09...@gmail.com <a09...@gmail.com> - Tel: +84 164.6339.217* *“Life is like riding a bicycle. To keep your balance, you must keep moving.”― Albert Einstein*