SparkJava“安全”方法对我来说根本不起作用

时间:2017-09-08 13:04:34

标签: spark-java

我完全无法在SparkJava Web服务中使用'安全'方法。

我在“App.java”类的顶部正确定义了“secure”命令。它正确引用了keystore.jks文件的完整路径(适用于Tomcat)并且密码正确。

然而,当我尝试从桌面(没有“安全”命令正确工作)启动服务时,我得到一个没有意义的Java IO异常:“/ Users / Test / Desktop是一个目录“

“安全”命令中指定的密钥库文件的完整路径是不同的。该路径是:/Users/Test/Keystores/keystore.jks

这是sparkJava返回的完整错误堆栈:

at org.eclipse.jetty.util.resource.PathResource.getInputStream(PathResource.java:396)
    at org.eclipse.jetty.util.security.CertificateUtils.getKeyStore(CertificateUtils.java:50)
    at org.eclipse.jetty.util.ssl.SslContextFactory.loadTrustStore(SslContextFactory.java:1043)
    at org.eclipse.jetty.util.ssl.SslContextFactory.load(SslContextFactory.java:255)
    at org.eclipse.jetty.util.ssl.SslContextFactory.doStart(SslContextFactory.java:220)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:113)
    at org.eclipse.jetty.server.SslConnectionFactory.doStart(SslConnectionFactory.java:72)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:113)
    at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:270)
    at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:81)
    at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.server.Server.doStart(Server.java:431)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at spark.embeddedserver.jetty.EmbeddedJettyServer.ignite(EmbeddedJettyServer.java:130)
    at spark.Service.lambda$init$2(Service.java:504)
    at java.lang.Thread.run(Thread.java:748)

如果有人能够使用此命令,那么我们将非常感谢您的帮助。

谢谢,

代码示例:

 public static void main(String[] args)
    {
        //------------------------
        // This code does not work
        // Despite the fact that
        // the Keystore works
        // correctly with Tomcat.
        //------------------------
        String keyStoreLocation =    "/<Path_to_keystore_file>/keystore.jks";
        String keyStorePassword = "password";
        secure(keyStoreLocation, keyStorePassword, "", "");
        .
        .
        .
        // other methods...

    }

0 个答案:

没有答案