javaioexceptionfilehandler

FileHandler causing IOException at FileKey


I call a java class from PLSQL Dev. My Logger.java calls the FileHandler with a string "C:\Logs\mylog.TXT"

fileHndlr = new FileHandler(logFileName, false);

and the result is:

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

Seems some rights is missing to create the file, what need to be checked?

UPDATE:

we installed the processmonitor to the server where the file operations happening and we found two suspicious events:

1) BUFFER OVERFLOW error at 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) SHARING VIOLATION error at CreateFile operation

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 

Solution

  • following actions need to be executed with sysdba user:

    GRANT READ,WRITE ON DIRECTORY userDirectory TO userSchema;
    
    Execute dbms_java.grant_permission('userSchema', 'java.io.FilePermission', 'userDirectory/*', 'read,write,execute,delete');