简体   繁体   中英

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. But latest event shows crashed, but current status always running.

The springboot adds 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?

By default tomcat is included by Spring Boot. You can always override it. That said, a simple Spring Boot app takes very little time to start.

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. If your app requires additional time, you can overwrite these settings with -t option on cf push .

The more proper question should be, why is your app taking more than 60 seconds to boot up? I suggest you try running the Spring boot app locally and find out what time it takes to boot. If you app is taking over 60 seconds, I suggest, you re-design the steps in the application.

If you are loading any data, re-engineer it by following 12 factor .

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 . See the Tomcat wiki for a full explanation. 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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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