且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Jetty Web服务器无法启动"java.io.IOException:无法读取文件:."

更新时间:2022-01-04 22:49:04

我们在Windows Server 2008上发现了相同的问题.当Jetty尝试读取模块配置文件时,发生了这种情况,这是由于检查可读性而导致的

We found the same problem on Windows Server 2008. It happens when Jetty is trying to read the module configuration files and is due to a fault in the check for readability.

在码头源文件FS.java第39行中,使用java.nio进行了检查,以查看该文件是否可读:

In the jetty source file FS.java line 39 a check is made using java.nio, to see if the file is readable:

public static boolean canReadFile(Path path)
{
    return Files.exists(path) && Files.isRegularFile(path) && Files.isReadable(path);
}

对isReadable的调用缓慢且失败,另请参见: http://mail.openjdk.java.net/pipermail/nio-discuss/2012-July/000672.html

The call to isReadable is slow and fails, see also: http://mail.openjdk.java.net/pipermail/nio-discuss/2012-July/000672.html

文件本身实际上是可读的,可以从Java成功读取,但是isReadable错误地返回false.

The file itself is in fact readable and can be successfully read from Java, but the isReadable incorrectly returns false.

有两种可能的解决方法:

There are two possible workarounds:

  1. 升级到Java 8
  2. 从Jetty来源中删除对isReadable的检查(在任何情况下,如果文件不可读,读取都会失败,但会出现异常).

(另请参见类似的问题无法启动码头通过窗口7中的命令进行服务)

(See also similar question unable to start jetty service through command in window 7)