spring 无法在Windows上启动cas-overlay-template-缺少\etc\cas\密钥库

pgky5nke  于 2022-10-30  发布在  Spring
关注(0)|答案(3)|浏览(167)

我尝试使用6.5分支在Windows 11和JDK 11(Eclipse Adoptium www.example.com)上运行https://github.com/apereo/cas-overlay-template11.0.16.1。我已经使用gradlew.bat运行了“createKeystore”和“copyCasConfiguration”gradle任务,它创建了以下文件:

  1. c:/etc/cas/cas.crt
  2. c:/etc/cas/密钥库
    1.配置cas.properties
  3. c:/etc/cas/config/log4j2.xml
    当我试图运行“gradlew.bat run”时,它遇到了以下错误:
2022-08-22 20:26:06,670 WARN [org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext] - <Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: FaException in thread "main" java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
        at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:59)
Caused by: org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
        at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181)
        at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54)
        at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356)
        at java.base/java.lang.Iterable.forEach(Iterable.java:75)
        at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155)
        at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123)
        at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)
        at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:164)
        at org.apereo.cas.web.CasWebApplication.main(CasWebApplication.java:62)
        ... 8 more
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:229)
        at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:43)
        at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178)
        ... 21 more
Caused by: java.lang.IllegalArgumentException: standardService.connector.startFailed
        at org.apache.catalina.core.StandardService.addConnector(StandardService.java:238)
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:282)
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:213)
        ... 23 more
Caused by: org.apache.catalina.LifecycleException: Protocol handler start failed
        at org.apache.catalina.connector.Connector.startInternal(Connector.java:1077)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.StandardService.addConnector(StandardService.java:234)
        ... 25 more
Caused by: java.lang.IllegalArgumentException: \etc\cas\thekeystore (The system cannot find the path specified)
        at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:107)
        at org.apache.tomcat.util.net.AbstractJsseEndpoint.initialiseSsl(AbstractJsseEndpoint.java:71)
        at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:235)
        at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1227)
        at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1313)
        at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:614)
        at org.apache.catalina.connector.Connector.startInternal(Connector.java:1074)
        ... 27 more
Caused by: java.io.FileNotFoundException: \etc\cas\thekeystore (The system cannot find the path specified)
        at java.base/java.io.FileInputStream.open0(Native Method)
        at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
        at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
        at java.base/java.io.FileInputStream.<init>(FileInputStream.java:112)
        at java.base/sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:86)
        at java.base/sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:184)
        at org.apache.catalina.startup.CatalinaBaseConfigurationSource.getResource(CatalinaBaseConfigurationSource.java:118)
        at org.apache.tomcat.util.net.SSLUtilBase.getStore(SSLUtilBase.java:199)
        at org.apache.tomcat.util.net.SSLHostConfigCertificate.getCertificateKeystore(SSLHostConfigCertificate.java:207)
        at org.apache.tomcat.util.net.SSLUtilBase.getKeyManagers(SSLUtilBase.java:283)
        at org.apache.tomcat.util.net.SSLUtilBase.createSSLContext(SSLUtilBase.java:247)
        at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:105)
        ... 33 more

我相信这是因为Gradle认为它是在Unix环境中运行,而不是在Windows环境中运行。我对c:/etc/cas/config/ www.example.com文件所做的任何更改cas.properties都被忽略了,这让我相信它在其他地方寻找cas文件夹(而不是c:/etc/cas)。有人有什么想法吗?

ttp71kqs

ttp71kqs1#

您可以在spring config中更改密钥库位置。您可以在www.example.com中传递该属性cas.properties,也可以使用命令行标志或ENV来传递该属性。以下是两个示例:
示例:绝对风路径

server.ssl.key-store=D:/dev/cas/etc/theKeystore.jks

示例:相对路径

server.ssl.key-store=file:etc/cas/thekeystore

顺便说一下,您还可以cas.properties使用cas.standalone.configurationDirectory参数更改www.example.com文件的位置。

java -jar build/libs/cas.war --cas.standalone.configurationDirectory=etc/cas/config --debug
hjqgdpho

hjqgdpho2#

有人有什么想法吗?
请阅读:https://apereo.github.io/cas/6.5.x/installation/Troubleshooting-Guide.html#review-logs
CAS服务器日志是确定问题根本原因的最佳资源,前提是您已配置了适当的日志级别。
您可以考虑将配置移动到CAS内部构建本身的一个应用程序.yml文件中,而不是将其保留在外部。
https://apereo.github.io/cas/6.5.x/configuration/Configuration-Server-Management-Standalone.html

55ooxyrt

55ooxyrt3#

尝试从tomcat切换到jetty作为一个嵌入式servlet服务器,它似乎有更好的windows支持,并 * 正确 * 寻找c:\etc\cas\thekeystore
为此,只需将gradle.properties文件中的appServer替换为-jetty
也许有一种方法可以教tomcat看正确的地方,但我没有找到,server.ssl.key-store设置没有任何效果。

相关问题