Spring boot首先出现,然后在Pivotal Cloud Foundry中自动启动

时间:2017-01-16 21:48:55

标签: java spring-boot cloudfoundry pivotal-cloud-foundry embedded-tomcat-8

当我推开我的弹簧靴时 - 1.3.3.RELEASE它长时间崩溃并最终开始。但最新事件显示崩溃,但当前状态始终在运行。

springboot添加了embed-tomcat -8.0.32。

错误:

2017-01-16T16:29:12.670-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.startup.Tomcat.start(Tomcat.java:345) ~[tomcat-embed-core-8.0.32.jar!/:8.0.32]
2017-01-16T16:29:12.685-05:00 [APP/PROC/WEB/0] [ERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2017-01-16T16:29:12.685-05:00 [APP/PROC/WEB/0] [ERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2017-01-16T16:29:12.685-05:00 [APP/PROC/WEB/0] [ERR] at java.lang.reflect.Method.invoke(Method.java:498)
2017-01-16T16:29:12.685-05:00 [APP/PROC/WEB/0] [ERR] Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
2017-01-16T16:29:12.685-05:00 [APP/PROC/WEB/0] [ERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2017-01-16T16:29:12.685-05:00 [APP/PROC/WEB/0] [ERR] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:62)
2017-01-16T16:29:12.685-05:00 [APP/PROC/WEB/0] [ERR] Caused by: org.springframework.context.ApplicationContextException: 
Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
2017-01-16T16:29:12.685-05:00 [APP/PROC/WEB/0] [ERR] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:54)
2017-01-16T16:29:12.685-05:00 [APP/PROC/WEB/0] [ERR] Caused by: java.lang.reflect.InvocationTargetException
2017-01-16T16:29:12.685-05:00 [APP/PROC/WEB/0] [ERR] at java.lang.Thread.run(Thread.java:745)
2017-01-16T16:29:12.685-05:00 [APP/PROC/WEB/0] [ERR] ... 1 more
2017-01-16T16:29:12.686-05:00 [APP/PROC/WEB/0] [ERR] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532)
2017-01-16T16:29:12.686-05:00 [APP/PROC/WEB/0] [ERR] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133)
2017-01-16T16:29:12.687-05:00 [APP/PROC/WEB/0] [ERR] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
2017-01-16T16:29:12.688-05:00 [APP/PROC/WEB/0] [ERR] at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
2017-01-16T16:29:12.688-05:00 [APP/PROC/WEB/0] [ERR] at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361)
2017-01-16T16:29:12.688-05:00 [APP/PROC/WEB/0] [ERR] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)
2017-01-16T16:29:12.688-05:00 [APP/PROC/WEB/0] [ERR] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191)
2017-01-16T16:29:12.688-05:00 [APP/PROC/WEB/0] [ERR] at bosch.cose.na.enterprise.CoseNaEnterpriseApplication.main(CoseNaEnterpriseApplication.java:19)
2017-01-16T16:29:12.688-05:00 [APP/PROC/WEB/0] [ERR] ... 6 more
2017-01-16T16:29:12.689-05:00 [APP/PROC/WEB/0] [ERR] at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:76)
2017-01-16T16:29:12.689-05:00 [APP/PROC/WEB/0] [ERR] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:160)
2017-01-16T16:29:12.689-05:00 [APP/PROC/WEB/0] [ERR] at org.apache.catalina.startup.Tomcat.start(Tomcat.java:345)
2017-01-16T16:29:12.689-05:00 [APP/PROC/WEB/0] [ERR] Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
2017-01-16T16:29:12.689-05:00 [APP/PROC/WEB/0] [ERR] at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:168)
2017-01-16T16:29:12.689-05:00 [APP/PROC/WEB/0] [ERR] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
2017-01-16T16:29:12.689-05:00 [APP/PROC/WEB/0] [ERR] at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:99)
2017-01-16T16:29:12.689-05:00 [APP/PROC/WEB/0] [ERR] ... 18 more
2017-01-16T16:29:12.689-05:00 [APP/PROC/WEB/0] [ERR] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)
2017-01-16T16:29:12.689-05:00 [APP/PROC/WEB/0] [ERR] ... 13 more
2017-01-16T16:29:12.689-05:00 [APP/PROC/WEB/0] [ERR] at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:89)
2017-01-16T16:29:12.689-05:00 [APP/PROC/WEB/0] [ERR] at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:457)
2017-01-16T16:29:12.689-05:00 [APP/PROC/WEB/0] [ERR] Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardServer[-1]]
2017-01-16T16:29:12.690-05:00 [APP/PROC/WEB/0] [ERR] ... 22 more
2017-01-16T16:29:12.690-05:00 [APP/PROC/WEB/0] [ERR] at org.apache.catalina.core.StandardService.startInternal(StandardService.java:441)
2017-01-16T16:29:12.690-05:00 [APP/PROC/WEB/0] [ERR] Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Tomcat]]
2017-01-16T16:29:12.690-05:00 [APP/PROC/WEB/0] [ERR] at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:769)
2017-01-16T16:29:12.690-05:00 [APP/PROC/WEB/0] [ERR] Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat]]
2017-01-16T16:29:12.690-05:00 [APP/PROC/WEB/0] [ERR] ... 20 more
2017-01-16T16:29:12.690-05:00 [APP/PROC/WEB/0] [ERR] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
2017-01-16T16:29:12.690-05:00 [APP/PROC/WEB/0] [ERR] at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:924)
2017-01-16T16:29:12.690-05:00 [APP/PROC/WEB/0] [ERR] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
2017-01-16T16:29:12.690-05:00 [APP/PROC/WEB/0] [ERR] ... 24 more
2017-01-16T16:29:12.690-05:00 [APP/PROC/WEB/0] [ERR] Caused by: org.apache.catalina.LifecycleException: A child container failed during start
2017-01-16T16:29:12.690-05:00 [APP/PROC/WEB/0] [ERR] at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
2017-01-16T16:29:12.788-05:00 [APP/PROC/WEB/0] [OUT] Exit status 0
2017-01-16T16:29:12.803-05:00 [CELL/0] [OUT] Exit status 0

如果有人知道原因,请告诉我。

如果有很长时间来启动应用程序,PCF会立即显示崩溃状态吗?

2 个答案:

答案 0 :(得分:0)

默认情况下,Spring Boot包含tomcat。你总是可以覆盖它。也就是说,一个简单的Spring Boot应用程序需要很少的时间来启动。

当您将LRP(微服务)推送到PCF时,在创建容器并且分段过程完成后,LRP启动并进入运行状态的默认时间间隔为60秒。如果您的应用需要额外时间,则可以使用-t上的cf push选项覆盖这些设置。

更合适的问题应该是,为什么你的应用程序启动时间超过60秒?我建议你尝试在本地运行Spring启动应用程序并找出启动所需的时间。如果您的应用程序占用时间超过60秒,我建议您重新设计应用程序中的步骤。

如果您要加载任何数据,请按照12 factor重新设计。

希望这有帮助!

答案 1 :(得分:0)

有可能在启动时遇到Tomcat阻塞问题,等待系统上的熵初始化SecureRandom。有关完整说明,请参阅Tomcat wiki。要查看这是否是正在发生的情况,请尝试为您的应用配置熵源以使用非阻止来源:

cf set-env <app name> JAVA_OPTS "-Djava.security.egd=file:///dev/urandom"