Jboss 7

时间:2018-07-12 06:02:02

标签: java linux file jboss

当前在生产环境中,我们面临的问题是“打开太多文件”。 该应用程序运行了2年,没有任何重大问题,但是突然间我们收到了以下错误消息

[org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 2) WFLYDS0012: Scan of /jboss/jboss-eap-7.0/mpayservices/deployments threw Exception: java.lang.RuntimeException: WFLYDS0032: Failed to list files in directory /jboss/jboss-eap-7.0/example/deployments. Check that the contents of the directory are readable.
    at org.jboss.as.server.deployment.scanner.FileSystemDeploymentService.listDirectoryChildren(FileSystemDeploymentService.java:1287)
    at org.jboss.as.server.deployment.scanner.FileSystemDeploymentService.scanDirectory(FileSystemDeploymentService.java:781)
    at org.jboss.as.server.deployment.scanner.FileSystemDeploymentService.scan(FileSystemDeploymentService.java:570)

 java.io.FileNotFoundException: /rsa/rsa_a.pem (Too many open files)
2018-07-11 10:39:13,015 ERROR [stderr] (default task-103)   at java.io.FileInputStream.open0(Native Method)
2018-07-11 10:39:13,015 ERROR [stderr] (default task-103)   at java.io.FileInputStream.open(FileInputStream.java:195)

这是打开文件的代码

private PrivateKey getPemPrivateKey(String filename) {

        File file = new File(filename);

        try (FileInputStream fileInputStream = new FileInputStream(file);
                DataInputStream dataInputInstream = new DataInputStream(fileInputStream);) {
            byte[] keyBytes = new byte[(int) file.length()];
            dataInputInstream.readFully(keyBytes);
            String privKeyPEM = new String(keyBytes);
            privKeyPEM = privKeyPEM.replace(PRIVATE_KEY_HEADER, "");
            privKeyPEM = privKeyPEM.replace(PRIVATE_KEY_FOOTER, "");

            byte[] decoded = Base64.decodeBase64(privKeyPEM);

            PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(decoded);
            KeyFactory keyFactory = KeyFactory.getInstance(RSA_KEY_FACTORY_INSTANCE);
            PrivateKey key = keyFactory.generatePrivate(spec);
            return key;
        }
        catch (NoSuchAlgorithmException | InvalidKeySpecException | IOException e) {
            e.printStackTrace();
            return null;
        }finally {

        }
    }

根据Java 1.7,我们将流置于尝试阻止状态以自动关闭资源。

但是仍然出现错误。但是,一旦服务器重启,它可以正常工作两个三个小时 之后问题又来了。

我们检查了ulimit -n

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 94482
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1024
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

我们正在等待两天的时间来解决此问题。但是,我们仍然无法解决该问题。

任何帮助将不胜感激!!!!

1 个答案:

答案 0 :(得分:0)

根据上述日志,FileSystemDeploymentService.listDirectoryChildren()是导致上述deployment.scanner服务错误的原因。

如果您不使用部署扫描器,则只需禁用它即可。看来这可能是操作系统问题。确保您正在使用的用户对该目录具有权限。

JBoss开发人员文档以获取更多参考。