简体   繁体   中英

Sping Boot Java backend application process gets killed

I have packaged my spring boot rest backend with mvn package .

When I run the jar on the server with java -jar ... the application starts and gets killed after a few seconds.

I also see that on the linux top view, that the java process goes over 300% CPU. Is that maybe the reason the process gets killed? And if yes, what can I do?

My spring boot application is not very big. Actually its almost empty.

Logs:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.2.RELEASE)

2020-01-26 07:40:36.423  INFO 8144 --- [           main] d.c.c.CarorderprocessApplication         : Starting CarorderprocessApplication v0.0.1-SNA
PSHOT on dedi1055.your-server.de with PID 8144 (/usr/www/users/waqfek/software_backend/carorderprocess-0.0.1-SNAPSHOT.jar started by waqfek in /us
r/www/users/waqfek/software_backend)
2020-01-26 07:40:36.426  INFO 8144 --- [           main] d.c.c.CarorderprocessApplication         : No active profile set, falling back to default
 profiles: default
2020-01-26 07:40:36.487  INFO 8144 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servle
t.context.AnnotationConfigServletWebServerApplicationContext@5cbc508c: startup date [Sun Jan 26 07:40:36 CET 2020]; root of context hierarchy
2020-01-26 07:40:37.614  INFO 8144 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotati
on.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerB
ySpringCGLIB$$d289c8bd] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-01-26 07:40:37.915  INFO 8144 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8081 (http)
2020-01-26 07:40:37.939  INFO 8144 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-01-26 07:40:37.940  INFO 8144 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.31
2020-01-26 07:40:37.949  INFO 8144 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library whi
ch allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib/x86_64-lin
ux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib]
2020-01-26 07:40:38.014  INFO 8144 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationCon
text
2020-01-26 07:40:38.014  INFO 8144 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization com
pleted in 1530 ms
2020-01-26 07:40:38.159  INFO 8144 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to:
[/*]
2020-01-26 07:40:38.159  INFO 8144 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [
/*]
2020-01-26 07:40:38.159  INFO 8144 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to:
 [/*]
2020-01-26 07:40:38.159  INFO 8144 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*
]
2020-01-26 07:40:38.160  INFO 8144 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to
: [/*]
2020-01-26 07:40:38.160  INFO 8144 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2020-01-26 07:40:38.302  INFO 8144 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2020-01-26 07:40:38.306  WARN 8144 --- [           main] com.zaxxer.hikari.util.DriverDataSource  : Registered driver with driverClassName=com.mysql.jdbc.Driver was not found, trying direct instantiation.
2020-01-26 07:40:38.491  INFO 8144 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2020-01-26 07:40:38.534  INFO 8144 --- [           main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2020-01-26 07:40:38.548  INFO 8144 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
        name: default
        ...]
2020-01-26 07:40:38.625  INFO 8144 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {5.2.17.Final}
2020-01-26 07:40:38.627  INFO 8144 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2020-01-26 07:40:38.661  INFO 8144 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2020-01-26 07:40:38.824  INFO 8144 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2020-01-26 07:40:39.086  INFO 8144 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-01-26 07:40:39.172  INFO 8144 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2020-01-26 07:40:39.406  INFO 8144 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@5cbc508c: startup date [Sun Jan 26 07:40:36 CET 2020]; root of context hierarchy
2020-01-26 07:40:39.444  WARN 8144 --- [           main] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-01-26 07:40:39.492  INFO 8144 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2020-01-26 07:40:39.494  INFO 8144 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2020-01-26 07:40:39.526  INFO 8144 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2020-01-26 07:40:39.526  INFO 8144 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2020-01-26 07:40:39.867  INFO 8144 --- [           main] .s.s.UserDetailsServiceAutoConfiguration :

Using generated security password: 8167df1e-24d1-4ebf-bb03-53e2385a1229

2020-01-26 07:40:40.030  INFO 8144 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@d2de489, org.springframework.security.web.context.SecurityContextPersistenceFilter@28cda624, org.springframework.security.web.header.HeaderWriterFilter@5340477f, org.springframework.security.web.csrf.CsrfFilter@6f15d60e, org.springframework.security.web.authentication.logout.LogoutFilter@71687585, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@66ea810, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter@5276d6ee, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@2f953efd, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@7eecb5b8, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@475c9c31, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@14bdbc74, org.springframework.security.web.session.SessionManagementFilter@7139992f, org.springframework.security.web.access.ExceptionTranslationFilter@446a1e84, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@169bb4dd]
2020-01-26 07:40:40.112  INFO 8144 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2020-01-26 07:40:40.113  INFO 8144 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'dataSource' has been autodetected for JMX exposure
2020-01-26 07:40:40.118  INFO 8144 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource]
2020-01-26 07:40:40.142  INFO 8144 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8081 (http) with context path ''
2020-01-26 07:40:40.145  INFO 8144 --- [           main] d.c.c.CarorderprocessApplication         : Started CarorderprocessApplication in 4.002 seconds (JVM running for 4.521)
Killed

...

top - 08:51:43 up 137 days, 11:30,  2 users,  load average: 0.86, 0.39, 0.30
Tasks:   4 total,   1 running,   3 sleeping,   0 stopped,   0 zombie
%Cpu(s): 30.7 us,  0.9 sy,  0.0 ni, 68.1 id,  0.2 wa,  0.0 hi,  0.1 si,  0.0 st
KiB Mem : 16119112 total,  4416660 free,  7332300 used,  4370152 buff/cache
KiB Swap:  4194300 total,  3625572 free,   568728 used.  8221460 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
20338 waqfek    20   0 7069792 299952  16808 S 247.5  1.9   0:07.45 java
16765 waqfek    20   0   38960   3032   2704 R   0.0  0.0   0:00.57 top
27373 waqfek    20   0   14092   3600   3048 S   0.0  0.0   0:00.16 bash
28746 waqfek    20   0   14072   3524   2988 S   0.0  0.0   0:00.00 bash

I only have three files in my project:

1.:

package ...

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;


@SpringBootApplication
public class CarorderprocessApplication {
    public static void main(String[] args) {
        SpringApplication.run(CarorderprocessApplication.class, args);
    }
}
  1. Then I have application.properties file with information for database connection and port.

  2. pom.xml :

    https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.springframework.boot spring-boot-starter-parent 2.0.2.RELEASE de.countandcare carorderprocess 0.0.1-SNAPSHOT carorderprocess Demo project for Spring Boot

    <dependencyManagement> <dependencies> </dependencies> </dependencyManagement> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> <version>2.2.1.RELEASE</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.17</version> </dependency> <dependency> <groupId>javax.persistence</groupId> <artifactId>persistence-api</artifactId> <version>1.0.2</version> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <version>5.5.2</version> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <executions> <execution> <id>compile</id> <phase>compile</phase> <goals> <goal>compile</goal> </goals> </execution> </executions> </plugin> </plugins> </build>

Some ideas to check:

  1. Try to run as detached: java -jar yourapp.jar &
  2. Try ( just once ) to run under root
  3. Check logs: journalctl -ex for details of who exactly has killed your application.

Depends on results, can plan next steps - typically which settings to adjust.

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