Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 虽然存在于jar中,但在jar中找不到密钥库文件_Java_Tomcat_Ssl_Https_Keystore - Fatal编程技术网

Java 虽然存在于jar中,但在jar中找不到密钥库文件

Java 虽然存在于jar中,但在jar中找不到密钥库文件,java,tomcat,ssl,https,keystore,Java,Tomcat,Ssl,Https,Keystore,我将属性设置为 LOGGER.debug("ksPath=>" + ksPath); httpsConnector.setAttribute("keystoreFile",ksPath); httpsConnector.setAttribute("keystorePass", keyStorePass); httpsConnector.setAttribute("clientAuth", "false"); httpsConnec

我将属性设置为

      LOGGER.debug("ksPath=>" + ksPath);
      httpsConnector.setAttribute("keystoreFile",ksPath);
      httpsConnector.setAttribute("keystorePass", keyStorePass);
      httpsConnector.setAttribute("clientAuth", "false");
      httpsConnector.setAttribute("sslProtocol", "TLS");
      httpsConnector.setAttribute("sslEnabledProtocols", tlsProtocols);
      httpsConnector.setAttribute("SSLEnabled", true);
      Connector defaultConnector = tomcat.getConnector();
      defaultConnector.setRedirectPort(port);
我在日志中看到的内容(运行时)

但是,部署失败,我看到日志如下所示

SEVERE: Failed to load keystore type JKS with path /shn/lp/jar:file:/shn/lp/main-1.0-SNAPSHOT-jar-with-dependencies.jar!/my.keystore due to /shn/lp/jar:file:/shn/lp/main-1.0-SNAPSHOT-jar-with-dependencies.jar!/my.keystore (No such file or directory)
java.io.FileNotFoundException: /shn/lp/jar:file:/shn/lp/main-1.0-SNAPSHOT-jar-with-dependencies.jar!/my.keystore (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:146)
    at org.apache.tomcat.util.net.jsse.JSSESocketFactory.getStore(JSSESocketFactory.java:413)
    at org.apache.tomcat.util.net.jsse.JSSESocketFactory.getKeystore(JSSESocketFactory.java:319)
    at org.apache.tomcat.util.net.jsse.JSSESocketFactory.getKeyManagers(JSSESocketFactory.java:577)
    at org.apache.tomcat.util.net.jsse.JSSESocketFactory.getKeyManagers(JSSESocketFactory.java:517)
    at org.apache.tomcat.util.net.jsse.JSSESocketFactory.init(JSSESocketFactory.java:462)
    at org.apache.tomcat.util.net.jsse.JSSESocketFactory.createSocket(JSSESocketFactory.java:209)
不同于

/shn/lp/jar:file:/shn/lp/main-1.0-SNAPSHOT-jar-with-dependencies.jar!my.keystore
后者以/shn/lp/

然而,为了断言,我看到该文件实际上存在于jar中

jar -tvf /shn/lp/main-1.0-SNAPSHOT-jar-with-dependencies.jar | grep my.keystore
  4704 Tue Jun 09 09:29:26 PDT 2015 my.keystore
怎么了


我如何解决这个问题

它似乎不理解协议,可能是因为缺少前导斜杠?您是否尝试过:

 String ksPath = this.getClass().getResource("/my.keystore").getFile();

似乎它不理解协议,可能是因为缺少前导斜杠?您是否尝试过:

 String ksPath = this.getClass().getResource("/my.keystore").getFile();

谢谢,现在它查找
java.io.FileNotFoundException:/shn/lp/file:/shn/lp/main-1.0-SNAPSHOT-jar-with-dependencies.jar/my.keystore(没有这样的文件或目录)
,但仍然找不到它。这个路径看起来不是很奇怪吗,它的
HOMEDIR+文件:/path/to/jar!my.keystore
?谢谢,现在它查找
java.io.FileNotFoundException:/shn/lp/file:/shn/lp/main-1.0-SNAPSHOT-jar-with-dependencies.jar/my.keystore(没有这样的文件或目录)
,但仍然找不到它。这个路径看起来不是很奇怪吗,它的
HOMEDIR+文件:/path/to/jar!my.keystore
?谢谢,现在它查找
java.io.FileNotFoundException:/shn/lp/file:/shn/lp/main-1.0-SNAPSHOT-jar-with-dependencies.jar/my.keystore(没有这样的文件或目录)
,但仍然找不到它。这个路径看起来不是很奇怪吗,它的
HOMEDIR+文件:/path/to/jar!my.keystore
FileInputStream
不支持类似
jar:path!条目
文件:路径
http:site/resource
,仅为文件系统中的实际文件路径名,绝对或相对。您可以选择(1)修改开源Tomcat以使用可以从jar条目读取的输入流,或者(2)将密钥库“文件”放在实际文件中。根据您的系统,您可以将文件放在不在“磁盘”上的“RAM”文件系统或“temp”文件系统中(现在“磁盘”并不总是磁盘)。
FileInputStream
不支持类似
jar:path!条目
文件:路径
http:site/resource
,仅为文件系统中的实际文件路径名,绝对或相对。您可以选择(1)修改开源Tomcat以使用可以从jar条目读取的输入流,或者(2)将密钥库“文件”放在实际文件中。根据您的系统,您可以将文件放在不在“磁盘”上的“RAM”文件系统或“temp”文件系统中(现在“磁盘”并不总是磁盘)。
FileInputStream
不支持类似
jar:path!条目
文件:路径
http:site/resource
,仅为文件系统中的实际文件路径名,绝对或相对。您可以选择(1)修改开源Tomcat以使用可以从jar条目读取的输入流,或者(2)将密钥库“文件”放在实际文件中。根据您的系统,您可以将文件放在不在“磁盘”上的“RAM”文件系统或“temp”文件系统中(今天的“磁盘”并不总是磁盘)。
 String ksPath = this.getClass().getResource("/my.keystore").getFile();