FileHandler 在 FileKey 处导致 IOException

FileHandler causing IOException at FileKey

我从 PLSQL Dev 调用了 java class。我的 Logger.java 使用字符串 "C:\Logs\mylog.TXT"

调用 FileHandler
fileHndlr = new FileHandler(logFileName, false);

结果是:

Exception in thread "Root Thread" java.lang.Error: java.io.IOException: sjonfile_fileinfo fais to get fileinfo
    at sun.nio.ch.FileKey.create(FileKey.java:41)
    at sun.nio.ch.FileChannelImpl$SharedFileLockTable.<init>(FileChannelImpl.java:1037)
    at sun.nio.ch.FileChannelImpl.fileLockTable(FileChannelImpl.java:806)
    at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:867)
    at java.nio.channels.FileChannel.tryLock(FileChannel.java:962)
    at java.util.logging.FileHandler.openFiles(FileHandler.java:394)
    at java.util.logging.FileHandler.<init>(FileHandler.java:268)
    at xxx.logger.Logger.logSetup(Logger.java:194)
Caused by: java.io.IOException: sjonfile_fileinfo fais to get fileinfo
    at sun.nio.ch.FileKey.init(Native Method)
    at sun.nio.ch.FileKey.create(FileKey.java:39)
    ... 9 more

似乎缺少创建文件的某些权限,需要检查什么?

更新:

我们在发生文件操作的服务器上安装了 processmonitor,我们发现了两个可疑事件:

1) QueryAllInformationFile 中的缓冲区溢出错误

Date & Time:    2015.03.02. 9:23:14
Event Class:    File System
Operation:  QueryAllInformationFile
Result: BUFFER OVERFLOW
Path:   C:\Logs\...\filename.lck
TID:    2708
Duration:   0.0000138
CreationTime:   2015.02.25. 15:49:13
LastAccessTime: 2015.02.25. 15:49:13
LastWriteTime:  2015.03.02. 9:23:14
ChangeTime: 2015.03.02. 9:23:14
FileAttributes: A
AllocationSize: 0
EndOfFile:  0
NumberOfLinks:  1
DeletePending:  False
Directory:  False
IndexNumber:    0x1500000007d793
EaSize: 0
Access: Generic Write, Read Attributes
Position:   0
Mode:   Synchronous IO Non-Alert
AlignmentRequirement:   Long

2) CreateFile 操作时出现共享违规错误

Date & Time:    2015.03.02. 9:23:20
Event Class:    File System
Operation:  CreateFile
Result: SHARING VIOLATION
Path:   C:\Logs\...\filename.lck
TID:    2708
Duration:   0.0000284
Desired Access: Read Attributes, Delete
Disposition:    Open
Options:    Non-Directory File, Open Reparse Point
Attributes: n/a
ShareMode:  Read, Write, Delete
AllocationSize: n/a 

需要使用 sysdba 用户执行以下操作:

GRANT READ,WRITE ON DIRECTORY userDirectory TO userSchema;

Execute dbms_java.grant_permission('userSchema', 'java.io.FilePermission', 'userDirectory/*', 'read,write,execute,delete');