![]() |
|
|
|
|
1
21st November 01:24
External User
Posts: 1
|
Hi, after trying hours to write a file to disc from a servlet, I tried
to get the "WriteFileServlet" servlet example running as described in http://www.oreilly.com/catalog/tomcat/chapter/ch06.pdf but it does NOT work: java.io.FileNotFoundException: /var/lib/tomcat4/webapps/ROOT/test.txt (Permission denied) at java.io.FileOutputStream.open(Native Method) at java.io.FileOutputStream.(FileOutputStream.java:10 2) at java.io.FileOutputStream.(FileOutputStream.java:62 ) at java.io.FileOutputStream.(FileOutputStream.java:13 2) at WriteFileServlet.service(WriteFileServlet.java:19) at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.ac cess$0(ApplicationFilterChain.java:197) at org.apache.catalina.core.ApplicationFilterChain$1. run(ApplicationFilterChain.java:176) at java.security.AccessController.doPrivileged(Native Method) at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:172) at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:243) .... After restarting tomcat, catalina.policy contains the appropriate grant codeBase "file:${catalina.home}/webapps/ROOT/-" { permission java.io.FilePermission "${catalina.home}/webapps/ROOT/test.txt", "read,write,delete"; }; Even if "${catalina.home}" is substituted by "/var/lib/tomcat4" or give AllPermission for this file or the whole ROOT-directory it does not work. Btw, file reading from servlet and file reading/writing from a seperate test.class started manually with "java test" works well. Could it be that the owner of tomcat4/webapps/ROOT is root and not tomcat4 and tomcat4 has thus no write permission? If so, where do I have to add that permission or where can I change TOMCAT_USER to root (/etc/tomcat4/tomcat4.conf does not exist!?)? Any ideas? |
|
|
|