Wildfly:使用RandomAccessFile时获得了权限被拒绝

时间:2018-06-02 13:21:46

标签: java wildfly permission-denied randomaccessfile

当我尝试为位于主机系统上的命名管道打开RandomAccessFile时,我收到以下错误

12:54:45,048 SEVERE [com.dev.app.servlet.BackgroundListener] (Thread-514) null: java.io.FileNotFoundException: /home/centos/file (Permission denied)
    at java.base/java.io.RandomAccessFile.open0(Native Method)
    at java.base/java.io.RandomAccessFile.open(RandomAccessFile.java:345)
    at java.base/java.io.RandomAccessFile.<init>(RandomAccessFile.java:259)
    at java.base/java.io.RandomAccessFile.<init>(RandomAccessFile.java:214)
    at java.base/java.io.RandomAccessFile.<init>(RandomAccessFile.java:127)
    at deployment.app.war//com.dev.app.util.Reader.run(Reader.java:35)

管道的操作系统权限如下

prwxrwxrwx. 1 centos centos 0 Jun  2 12:50 file

这是我用来访问文件的代码

RandomAccessFile pipe = null;
BufferedReader br = null;
try {
     pipe = new RandomAccessFile(Paths.PIPE, "rw");
} catch (FileNotFoundException ex) {
     Logger.getLogger(BackgroundListener.class.getName()).log(Level.SEVERE, null, ex);
}

我的服务器配置:Wildfly 13,Jdk 10,Centos 7

在debian机器上,相同的war文件正常工作,可能是问题的原因?

非常感谢。

1 个答案:

答案 0 :(得分:0)

得到解决方案,这是一个许可问题。 对于/ home / centos / file,777设置了Altought权限,文件夹/ home / centos的权限设置为700

centos@ip ~ $ getfacl /home/centos
# file: home/centos
# owner: centos
# group: centos
user::rwx
group::---
other::---

通过修复许可解决,谢谢。

相关问题