简体   繁体   English

Spring Boot先失败,然后在Pivotal Cloud Foundry中自动启动

[英]Spring boot rashes first and then start automatically in Pivotal Cloud Foundry

When I push my spring boot - 1.3.3.RELEASE it crashes for long time and finally starts. 当我按一下我的弹簧靴-1.3.3.RELEASE时,它崩溃了很长时间,终于启动了。 But latest event shows crashed, but current status always running. 但是最新事件显示崩溃了,但是当前状态始终在运行。

The springboot adds embed-tomcat -8.0.32. springboot添加了embed-tomcat -8.0.32。

Error: 错误:

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

Please let me know if anyone is aware of the reason. 如果有人知道原因,请告诉我。

PCF will show the status Crashed immediately if there long time process to get an application started? 如果需要很长时间才能启动应用程序,PCF将立即显示“已崩溃”状态。

By default tomcat is included by Spring Boot. 默认情况下,Spring Boot包含tomcat。 You can always override it. 您始终可以覆盖它。 That said, a simple Spring Boot app takes very little time to start. 也就是说,一个简单的Spring Boot应用程序只需很少的时间即可启动。

When you push an LRP (microservice) to PCF, after the container is created, and the staging process is completed, the default interval is 60 seconds for an LRP to start and get into a running state. 当您将LRP(微服务)推送到PCF时,在创建容器并完成过渡过程之后,LRP启动并进入运行状态的默认间隔为60秒。 If your app requires additional time, you can overwrite these settings with -t option on cf push . 如果您的应用需要更多时间,则可以使用cf push上的-t选项覆盖这些设置。

The more proper question should be, why is your app taking more than 60 seconds to boot up? 更恰当的问题应该是,为什么您的应用程序需要60秒钟以上才能启动? I suggest you try running the Spring boot app locally and find out what time it takes to boot. 我建议您尝试在本地运行Spring Boot应用程序,并找出启动时间。 If you app is taking over 60 seconds, I suggest, you re-design the steps in the application. 如果您的应用程序耗时超过60秒,我建议您重新设计应用程序中的步骤。

If you are loading any data, re-engineer it by following 12 factor . 如果要加载任何数据,请按照12因子重新设计。

Hope this helps! 希望这可以帮助!

It is possible you are running into the problem of Tomcat blocking on startup waiting for entropy on the system to initialize SecureRandom . 您可能会遇到启动时Tomcat阻塞的问题,等待系统上的熵初始化SecureRandom See the Tomcat wiki for a full explanation. 有关完整说明,请参见Tomcat Wiki To see if this is what is happening, try configuring the entropy source for your app to use a non-blocking source: 要查看是否正在发生这种情况,请尝试为您的应用配置熵源以使用非阻塞源:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM