Wildfly:使用 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);
}

我的服务器配置:野蝇 13、Jdk 10、Centos 7

在 debian 机器上,相同的战争文件可以正常工作,问题的原因可能是什么?

非常感谢。

有解决方案,这是一个权限问题。 在 777 上为/home/centos/file 设置了 Altought 权限,在 700 上设置了文件夹/home/centos

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

通过修复权限解决,谢谢。

最新更新