1

I start my Spring Boot webapp using java -jar xxx.jar, but after running for a while the app shuts down by itself. Here is the --debug log

22:55:36.187 [http-nio-7082-exec-10] DEBUG o.s.web.servlet.DispatcherServlet -    Successfully completed request
22:55:36.187 [http-nio-7082-exec-10] DEBUG o.s.b.c.w.OrderedRequestContextFilter - Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@40d2cb04
01:06:52.227 [Thread-4] INFO  o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext - Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@633761b6: startup date [Tue Mar 08 22:54:54 CST 2016]; root of context hierarchy
01:06:52.229 [Thread-4] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'lifecycleProcessor'
01:06:52.229 [Thread-4] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@2db493c7: defining beans [......]; root of factory hierarchy
01:06:52.234 [Thread-4] DEBUG o.s.b.f.s.DisposableBeanAdapter - Invoking destroy() on bean with name 'mbeanExporter'
01:06:52.234 [Thread-4] INFO  o.s.j.e.a.AnnotationMBeanExporter - Unregistering JMX-exposed beans on shutdown
01:06:52.238 [Thread-4] DEBUG o.s.b.f.s.DisposableBeanAdapter - Invoking destroy() on bean with name 'mvcValidator'
01:06:52.242 [Thread-4] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Retrieved dependent beans for bean '(inner bean)#62a4e999': [tzsUserDao]
01:06:52.242 [Thread-4] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Retrieved dependent beans for bean '(inner bean)#38e46e67': [(inner bean)#62a4e999]
01:06:52.243 [Thread-4] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Retrieved dependent beans for bean '(inner bean)#7a25d5eb': [tzsUserActionDao]
01:06:52.243 [Thread-4] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Retrieved dependent beans for bean '(inner bean)#2298ca79': [(inner bean)#7a25d5eb]
01:06:52.244 [Thread-4] DEBUG o.s.b.f.s.DisposableBeanAdapter - Invoking destroy() on bean with name 'jpaMappingContext'
01:06:52.244 [Thread-4] DEBUG o.s.b.f.s.DisposableBeanAdapter - Invoking destroy() on bean with name 'entityManagerFactory'
01:06:52.245 [Thread-4] INFO  o.s.o.j.LocalContainerEntityManagerFactoryBean - Closing JPA EntityManagerFactory for persistence unit 'default'
01:06:52.245 [Thread-4] DEBUG o.h.internal.SessionFactoryImpl - HHH000031: Closing
01:06:52.245 [Thread-4] DEBUG o.h.s.i.AbstractServiceRegistryImpl - Implicitly destroying ServiceRegistry on de-registration of all child ServiceRegistries
01:06:52.246 [Thread-4] DEBUG o.h.b.r.i.BootstrapServiceRegistryImpl - Implicitly destroying Boot-strap registry on de-registration of all child ServiceRegistries
01:06:52.246 [Thread-4] DEBUG o.h.j.i.EntityManagerFactoryRegistry - Remove: name=default
01:06:52.246 [Thread-4] DEBUG o.s.b.f.s.DisposableBeanAdapter - Invoking destroy() on bean with name 'httpPutFormContentFilter'
01:06:52.246 [Thread-4] DEBUG o.s.b.f.s.DisposableBeanAdapter - Invoking destroy() on bean with name 'hiddenHttpMethodFilter'
01:06:52.247 [Thread-4] DEBUG o.s.b.f.s.DisposableBeanAdapter - Invoking destroy() on bean with name 'requestContextFilter'
01:06:52.248 [Thread-4] DEBUG o.s.b.f.s.DisposableBeanAdapter - Invoking destroy() on bean with name 'characterEncodingFilter'
01:06:52.249 [Thread-4] DEBUG o.s.b.f.s.DisposableBeanAdapter - Invoking destroy method 'close' on bean with name 'dataSource'
01:06:52.254 [Thread-4] DEBUG o.s.b.f.s.DisposableBeanAdapter - Invoking destroy() on bean with name 'org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor'
William Price
  • 4,033
  • 1
  • 35
  • 54
jinsong ai
  • 121
  • 2
  • 9
  • Take a look to this, maybe it is a similar problem: http://stackoverflow.com/questions/22380119/why-my-spring-boot-app-always-shutdown?rq=1 – Andrea Girardi Mar 09 '16 at 08:57
  • Look at the other stack overflow questions: you should add the code (or part of it) otherwise it's complicated to understand the reason for which something goes wrong or, generally, the context of your question. – Andrea Girardi Mar 09 '16 at 08:58
  • Judging by `Thread-4`, I would guess that it's a JVM shutdown hook that's closing the application context. That means that something has asked the JVM to shut down. It's impossible to say what that is without some more information. If you're running on Linux it could be the OOM Killer, although I'm not sure if it sends `SIGTERM` which would all the shutdown hook to run, or `SIGKILL` which would not. – Andy Wilkinson Mar 09 '16 at 11:31

1 Answers1

7

I know why: because I start my Spring Boot webapp using

java -jar xxx.jar

but when I start it by

nohup java -jar xxx.jar

the application will run correct and won't be terminated when the SSH session terminates.

From https://linux.101hacks.com/unix/nohup-command/

When you execute a Unix job in the background ( using &, bg command), and logout from the session, your process will get killed. You can avoid this using several methods — executing the job with nohup, or making it as batch job using at, batch or cron command.

Youans
  • 4,801
  • 1
  • 31
  • 57
jinsong ai
  • 121
  • 2
  • 9
  • This works also if you have same probelm running command using `&` more on https://linux.101hacks.com/unix/nohup-command/ – Youans Jun 02 '19 at 23:00