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

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

我尝试使用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”时,它遇到了以下错误:
  1. 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
  2. at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  3. at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  4. at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  5. at java.base/java.lang.reflect.Method.invoke(Method.java:566)
  6. at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
  7. at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
  8. at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
  9. at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:59)
  10. 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
  11. at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181)
  12. at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54)
  13. at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356)
  14. at java.base/java.lang.Iterable.forEach(Iterable.java:75)
  15. at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155)
  16. at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123)
  17. at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935)
  18. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)
  19. at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
  20. at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732)
  21. at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414)
  22. at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)
  23. at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:164)
  24. at org.apereo.cas.web.CasWebApplication.main(CasWebApplication.java:62)
  25. ... 8 more
  26. Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
  27. at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:229)
  28. at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:43)
  29. at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178)
  30. ... 21 more
  31. Caused by: java.lang.IllegalArgumentException: standardService.connector.startFailed
  32. at org.apache.catalina.core.StandardService.addConnector(StandardService.java:238)
  33. at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:282)
  34. at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:213)
  35. ... 23 more
  36. Caused by: org.apache.catalina.LifecycleException: Protocol handler start failed
  37. at org.apache.catalina.connector.Connector.startInternal(Connector.java:1077)
  38. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
  39. at org.apache.catalina.core.StandardService.addConnector(StandardService.java:234)
  40. ... 25 more
  41. Caused by: java.lang.IllegalArgumentException: \etc\cas\thekeystore (The system cannot find the path specified)
  42. at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:107)
  43. at org.apache.tomcat.util.net.AbstractJsseEndpoint.initialiseSsl(AbstractJsseEndpoint.java:71)
  44. at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:235)
  45. at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1227)
  46. at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1313)
  47. at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:614)
  48. at org.apache.catalina.connector.Connector.startInternal(Connector.java:1074)
  49. ... 27 more
  50. Caused by: java.io.FileNotFoundException: \etc\cas\thekeystore (The system cannot find the path specified)
  51. at java.base/java.io.FileInputStream.open0(Native Method)
  52. at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
  53. at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
  54. at java.base/java.io.FileInputStream.<init>(FileInputStream.java:112)
  55. at java.base/sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:86)
  56. at java.base/sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:184)
  57. at org.apache.catalina.startup.CatalinaBaseConfigurationSource.getResource(CatalinaBaseConfigurationSource.java:118)
  58. at org.apache.tomcat.util.net.SSLUtilBase.getStore(SSLUtilBase.java:199)
  59. at org.apache.tomcat.util.net.SSLHostConfigCertificate.getCertificateKeystore(SSLHostConfigCertificate.java:207)
  60. at org.apache.tomcat.util.net.SSLUtilBase.getKeyManagers(SSLUtilBase.java:283)
  61. at org.apache.tomcat.util.net.SSLUtilBase.createSSLContext(SSLUtilBase.java:247)
  62. at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:105)
  63. ... 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来传递该属性。以下是两个示例:
示例:绝对风路径

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

示例:相对路径

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

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

  1. 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设置没有任何效果。

相关问题