Skip to content
Advertisement

Problems with launch spring boot jar on ubuntu server. Error starting ApplicationContext

I have configured nginx to fit my code. My code works well on Windows and now I’m trying to deploy it to Ubuntu. I run jar and it fail. Logs:

     :: Spring Boot ::                (v2.4.2)
    
    2021-03-13 06:52:55.131  INFO 4305 --- [           main] com.social.socialmedia.Application       : Starting Application v1.0-SNAPSHOT using Java 1.8.0_282 o
    n amber with PID 4305 (/home/kirill/social-media-1.0-SNAPSHOT.jar started by kirill in /home/kirill)
    2021-03-13 06:52:55.149  INFO 4305 --- [           main] com.social.socialmedia.Application       : No active profile set, falling back to default profiles:
    default
    2021-03-13 06:53:00.135  INFO 4305 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mod
    e.
    2021-03-13 06:53:00.515  INFO 4305 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 332 ms. Found
     2 JPA repository interfaces.
    2021-03-13 06:53:03.824  INFO 4305 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.access.expression.meth
    od.DefaultMethodSecurityExpressionHandler@1fb700ee' of type [org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler] is
     not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    2021-03-13 06:53:03.861  INFO 4305 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'methodSecurityMetadataSource' of type [org.springfr
    amework.security.access.method.DelegatingMethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not elig
    ible for auto-proxying)
    2021-03-13 06:53:06.121  INFO 4305 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 80 (http)
    2021-03-13 06:53:06.194  INFO 4305 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
    2021-03-13 06:53:06.195  INFO 4305 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.41]
    2021-03-13 06:53:06.517  INFO 4305 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
    2021-03-13 06:53:06.518  INFO 4305 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1
    1035 ms
    2021-03-13 06:53:08.111  INFO 4305 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
    2021-03-13 06:53:08.596  INFO 4305 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.27.Final
    2021-03-13 06:53:09.579  INFO 4305 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
    2021-03-13 06:53:10.113  INFO 4305 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
    2021-03-13 06:53:11.762  INFO 4305 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
    2021-03-13 06:53:12.004  INFO 4305 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQ
    LDialect
    2021-03-13 06:53:19.889  INFO 4305 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hiberna
    te.engine.transaction.jta.platform.internal.NoJtaPlatform]
    2021-03-13 06:53:19.925  INFO 4305 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit
     'default'
    2021-03-13 06:53:22.331  WARN 4305 --- [           main] JpaBaseConfiguration$JpaWebConfiguration : 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
    2021-03-13 06:53:27.076  INFO 4305 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Will secure any request with [org.springframework.securit
    y.web.context.request.async.WebAsyncManagerIntegrationFilter@2364305a, org.springframework.security.web.context.SecurityContextPersistenceFilter@72445aba, or
    g.springframework.security.web.header.HeaderWriterFilter@7829b776, org.springframework.security.web.csrf.CsrfFilter@4b3c354a, org.springframework.security.we
    b.authentication.logout.LogoutFilter@56f6d40b, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@5536379e, org.springframe
    work.security.web.savedrequest.RequestCacheAwareFilter@1c80e49b, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@15c25153
    , org.springframework.security.web.authentication.AnonymousAuthenticationFilter@470a696f, org.springframework.security.web.session.SessionManagementFilter@5b
    64c4b7, org.springframework.security.web.access.ExceptionTranslationFilter@1433046b, org.springframework.security.web.access.intercept.FilterSecurityIntercep
    tor@350ec41e]
    2021-03-13 06:53:28.106  INFO 4305 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
    2021-03-13 06:53:30.531  WARN 4305 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - can
    celling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springfr
    amework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
    2021-03-13 06:53:30.543  INFO 4305 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
    2021-03-13 06:53:30.553  INFO 4305 --- [           main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'de
    fault'
    2021-03-13 06:53:30.568  INFO 4305 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
    2021-03-13 06:53:30.612  INFO 4305 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
    2021-03-13 06:53:30.622  INFO 4305 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
    2021-03-13 06:53:30.751  INFO 4305 --- [           main] ConditionEvaluationReportLoggingListener :
    
    Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
    2021-03-13 06:53:30.885 ERROR 4305 --- [           main] o.s.boot.SpringApplication               : Application run failed
    
    org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.W
    ebServerException: Unable to start embedded Tomcat server
            at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181) ~[spring-context-5.3.3.jar!/:5.3.3]
            at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54) ~[spring-context-5.3.3.jar!/:5.3.3]
            at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) ~[spring-context-5.3.3.jar!
    /:5.3.3]
            at java.lang.Iterable.forEach(Iterable.java:75) ~[na:1.8.0_282]
            at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155) ~[spring-context-5.3.3.jar!/:5.3.3]
            at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123) ~[spring-context-5.3.3.jar!/:5.3.3]
            at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:940) ~[spring-context-5.3.3.jar!/:5.3
    .3]
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:591) ~[spring-context-5.3.3.jar!/:5.3.3]
            at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) ~[spring-boot
    -2.4.2.jar!/:2.4.2]
            at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767) [spring-boot-2.4.2.jar!/:2.4.2]
            at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.4.2.jar!/:2.4.2]
            at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426) [spring-boot-2.4.2.jar!/:2.4.2]
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:326) [spring-boot-2.4.2.jar!/:2.4.2]
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:1311) [spring-boot-2.4.2.jar!/:2.4.2]
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300) [spring-boot-2.4.2.jar!/:2.4.2]
            at com.social.socialmedia.Application.main(Application.java:10) [classes!/:1.0-SNAPSHOT]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_282]
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_282]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_282]
            at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_282]
            at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) [social-media-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
            at org.springframework.boot.loader.Launcher.launch(Launcher.java:107) [social-media-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
            at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) [social-media-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
            at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) [social-media-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
    Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
            at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:229) ~[spring-boot-2.4.2.jar!/:2.4.2]
            at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:43) ~[spring-boot-2.4.2.jar!/:2.4.
    2]
            at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) ~[spring-context-5.3.3.jar!/:5.3.3]
            ... 23 common frames omitted
    Caused by: java.lang.IllegalArgumentException: standardService.connector.startFailed
            at org.apache.catalina.core.StandardService.addConnector(StandardService.java:244) ~[tomcat-embed-core-9.0.41.jar!/:9.0.41]
            at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:282) ~[spring-boot-2.4.2.jar!/:2.
    4.2]
            at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:213) ~[spring-boot-2.4.2.jar!/:2.4.2]
            ... 25 common frames omitted
    Caused by: org.apache.catalina.LifecycleException: Protocol handler start failed
            at org.apache.catalina.connector.Connector.startInternal(Connector.java:1067) ~[tomcat-embed-core-9.0.41.jar!/:9.0.41]
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.41.jar!/:9.0.41]
            at org.apache.catalina.core.StandardService.addConnector(StandardService.java:240) ~[tomcat-embed-core-9.0.41.jar!/:9.0.41]
            ... 27 common frames omitted
    Caused by: java.net.SocketException: Permission denied
            at sun.nio.ch.Net.bind0(Native Method) ~[na:1.8.0_282]
            at sun.nio.ch.Net.bind(Net.java:461) ~[na:1.8.0_282]
            at sun.nio.ch.Net.bind(Net.java:453) ~[na:1.8.0_282]
            at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:222) ~[na:1.8.0_282]
            at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:85) ~[na:1.8.0_282]
            at org.apache.tomcat.util.net.NioEndpoint.initServerSocket(NioEndpoint.java:228) ~[tomcat-embed-core-9.0.41.jar!/:9.0.41]
            at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:211) ~[tomcat-embed-core-9.0.41.jar!/:9.0.41]
            at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1159) ~[tomcat-embed-core-9.0.41.jar!/:9.0.41]
            at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1245) ~[tomcat-embed-core-9.0.41.jar!/:9.0.41]
            at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:603) ~[tomcat-embed-core-9.0.41.jar!/:9.0.41]
            at org.apache.catalina.connector.Connector.startInternal(Connector.java:1064) ~[tomcat-embed-core-9.0.41.jar!/:9.0.41]
            ... 29 common frames comitte

My propeties:

spring.datasource.url=jdbc:postgresql://localhost:5432/socialmedia
   spring.datasource.username=postgres
   spring.datasource.password=root
   spring.jpa.generate-ddl=false
   spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
   spring.jpa.show-sql=false
   spring.jpa.hibernate.ddl-auto=validate
   spring.flyway.enabled=false
   spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
   spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
   spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl

continues code:

upload.path=home/kirill/uploads

#properties for MailSender

#smptps – Not secure connection

spring.mail.host=smtp.yandex.ru

#test

spring.mail.username= HIDED EMAIL

spring.mail.password=password

spring.mail.port=465

spring.mail.protocol=smtps

mail.debug=false

recaptcha.secret=hided secret

spring.session.jdbc.initialize-schema=always

spring.session.jdbc.table-name=SPRING_SESSION

hostname= HIDED HOST

server.port=80

Everywhere I looked for solutions, I did not find anything. I don’t understand this error

Advertisement

Answer

You are trying to run the application on port 80.

server.port=80

Ports < 1024 are only allowed to run as root.

Either run it as root (not recommended) or use another port.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement