I have faced strange poblem while writing Grails application deployed on Tomcat.
After creating simple test controller I want to write test contents in
package com
package com.domain.controller
import java.io.File;
import java.io.PrintWriter;
class TestController {
def index() {
// test
try {
PrintWriter writer = new PrintWriter("/home/user/domains/domain.com/public_html/the-file-name.txt");
writer.println("The first line");
writer.println("The second line");
writer.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
I get an exception:
Class java.io.FileNotFoundException Message
/home/user/domains/domain.com/public_html/the-file-name.txt (Brak
dost?pu)
I have set the chmod to 777 into /home/user/domains/domain.com/public_html/
. And tomcat7.tomcat7
is owner. I have also tried to create this file with the access rights 777 and ownership set to tomcat7, but I still get an exception:
ls -al /home/user/domains/domain.com/public_html
razem 16
drwxrwxrwx 3 tomcat7 tomcat7 4096 01-08 23:25 .
drwxr-xr-x 8 user user 4096 12-16 17:14 ..
-rwxrwxrwx 1 tomcat7 tomcat7 0 01-08 23:25 the-file-name.txt
What conditions in OS should I also meet?
I would be very gratefull if someone could clarify the problem.
EDIT:
I have created the directory under /path1
, set 777. The files are stored perfectly.
I have also crated the directory under under /path2/testdir
, but path2 has no permission 777 and chown. It also works. I have also testes the testdir
with characters .
and _
, also works.
I am very investigative and cannot understand the behaviour.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…