java.io.IOException: Couldn't get lock for

眉间皱痕 提交于 2019-12-04 12:35:24
jkuruvila

@Catheryan

I also had the same issue. For me issue was:

private static final String FILE_PATH="/home/jeril/Logs.log";
handler = new FileHandler(FILE_PATH);

FILE_PATH was WRONG

This issue is a long standing bug in FileHandler (reported way back in March 2005, in Java 4):

JDK-6244047 : impossible to specify directories to logging FileHandler unless they exist

Quoting from the description of this bug:

If you specify a patern to the FileHandler that contains directories that don't currently exist then the FileHandler will fail to initialise even if the directories can be created

Its mentioned that it has been fixed in Java 8. For versions earlier than 8, the workaround is to either not use any directory in the pattern used for a FileHandler or use a directory which actually exists on the disk.

I think this is due to there being more than one instance of the logger that has it open or some other external application has it open with a read/write lock.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!