尽管chmod 777,java.io.FileNotFoundException(权限被拒绝) [英] java.io.FileNotFoundException (permission denied) despite chmod 777

查看:3720
本文介绍了尽管chmod 777,java.io.FileNotFoundException(权限被拒绝)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Tomcat上编写Grails应用程序时遇到了奇怪的问题。

I have faced strange poblem while writing Grails application deployed on Tomcat.

创建简单的测试控制器之后我想在
package com中编写测试内容/ p>

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);
                }
        }
}

我得到一个例外:


类java.io.FileNotFoundException消息
/home/user/domains/domain.com/public_html/the-file-name .txt(Brak $ b $bdostępu)

Class java.io.FileNotFoundException Message /home/user/domains/domain.com/public_html/the-file-name.txt (Brak dostępu)

我已将chmod设置为777到 / home /用户/域/ domain.com /的public_html / 。并且 tomcat7.tomcat7 是所有者。我还试图创建这个文件,访问权限777和所有权设置为tomcat7,但我仍然得到一个例外:

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

我应该在OS中遇到什么条件?

What conditions in OS should I also meet?

我会非常感谢有人能澄清问题。

I would be very gratefull if someone could clarify the problem.

编辑

我在 / path1 下创建了目录,设置为777.文件存储完美。
我还创建了 / path2 / testdir 下的目录,但是path2没有权限777和chown。它也有效。我还测试了 testdir ,字符为 _ ,也很有效。

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.

推荐答案

确保您已经读取并执行了对所有父目录的访问权。

Ensure you that you have read and execute access to all parent directories as well.

示例:
chmod o + x / home / user

这篇关于尽管chmod 777,java.io.FileNotFoundException(权限被拒绝)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆