it-swarm-ja.com

SpringBootを開始できませんでした

エラーが発生し、2時間何が問題だったのかを突き止めようとしましたが、修正できません。

Java -jarコマンドを使用してSpringBootアプリを実行しました。これはパッケージであり、起動できませんでした。

プロパティファイルを設定してポートを80に設定し、firewalldを無効にして、centos7マシンで実行しました。 netstatコマンドを試しましたが、ポート80のサービスがなかったので、ポートの問題ではないと思います。

これはエラーログです:

2019-01-21 16:02:56.183  INFO 8158 --- [           main] com.springboot.PjsSpringBootApplication  : Starting PjsSpringBootApplication v1.0 on carpfishncptest1 with PID 8158 (/home/jh31/pjs-spring-boot/target/pjs-spring-boot-1.0.jar started by jh31 in /home/jh31/pjs-spring-boot/target)
2019-01-21 16:02:56.186  INFO 8158 --- [           main] com.springboot.PjsSpringBootApplication  : No active profile set, falling back to default profiles: default
2019-01-21 16:02:57.702  INFO 8158 --- [           main] o.s.b.w.embedded.Tomcat.TomcatWebServer  : Tomcat initialized with port(s): 80 (http)
2019-01-21 16:02:57.729  INFO 8158 --- [           main] o.Apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-01-21 16:02:57.730  INFO 8158 --- [           main] org.Apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.14]
2019-01-21 16:02:57.740  INFO 8158 --- [           main] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the Java.library.path: [/usr/Java/packages/lib/AMD64:/usr/lib64:/lib64:/lib:/usr/lib]
2019-01-21 16:02:57.812  INFO 8158 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-01-21 16:02:57.813  INFO 8158 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1571 ms
2019-01-21 16:02:58.056  INFO 8158 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-01-21 16:02:58.174  WARN 8158 --- [           main] o.s.b.a.m.MustacheAutoConfiguration      : Cannot find template location: classpath:/templates/ (please add some templates, check your Mustache configuration, or set spring.mustache.check-template-location=false)
2019-01-21 16:02:58.192  INFO 8158 --- [           main] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page: class path resource [static/index.html]
2019-01-21 16:02:58.277 ERROR 8158 --- [           main] org.Apache.catalina.util.LifecycleBase   : Failed to start component [Connector[HTTP/1.1-80]]

org.Apache.catalina.LifecycleException: Protocol handler start failed
        at org.Apache.catalina.connector.Connector.startInternal(Connector.Java:1004) ~[Tomcat-embed-core-9.0.14.jar!/:9.0.14]
        at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:183) ~[Tomcat-embed-core-9.0.14.jar!/:9.0.14]
        at org.Apache.catalina.core.StandardService.addConnector(StandardService.Java:226) [Tomcat-embed-core-9.0.14.jar!/:9.0.14]
        at org.springframework.boot.web.embedded.Tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.Java:259) [spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
        at org.springframework.boot.web.embedded.Tomcat.TomcatWebServer.start(TomcatWebServer.Java:197) [spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.startWebServer(ServletWebServerApplicationContext.Java:311) [spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.Java:164) [spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.Java:549) [spring-context-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.Java:142) [spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.Java:775) [spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.Java:397) [spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.Java:316) [spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.Java:1260) [spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.Java:1248) [spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
        at com.springboot.PjsSpringBootApplication.main(PjsSpringBootApplication.Java:10) [classes!/:1.0]
        at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_201]
        at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:62) ~[na:1.8.0_201]
        at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43) ~[na:1.8.0_201]
        at Java.lang.reflect.Method.invoke(Method.Java:498) ~[na:1.8.0_201]
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.Java:48) [pjs-spring-boot-1.0.jar:1.0]
        at org.springframework.boot.loader.Launcher.launch(Launcher.Java:87) [pjs-spring-boot-1.0.jar:1.0]
        at org.springframework.boot.loader.Launcher.launch(Launcher.Java:50) [pjs-spring-boot-1.0.jar:1.0]
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.Java:51) [pjs-spring-boot-1.0.jar:1.0]
Caused by: Java.net.SocketException: Permission denied
        at Sun.nio.ch.Net.bind0(Native Method) ~[na:1.8.0_201]
        at Sun.nio.ch.Net.bind(Net.Java:433) ~[na:1.8.0_201]
        at Sun.nio.ch.Net.bind(Net.Java:425) ~[na:1.8.0_201]
        at Sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.Java:223) ~[na:1.8.0_201]
        at Sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.Java:74) ~[na:1.8.0_201]
        at org.Apache.Tomcat.util.net.NioEndpoint.initServerSocket(NioEndpoint.Java:236) ~[Tomcat-embed-core-9.0.14.jar!/:9.0.14]
        at org.Apache.Tomcat.util.net.NioEndpoint.bind(NioEndpoint.Java:210) ~[Tomcat-embed-core-9.0.14.jar!/:9.0.14]
        at org.Apache.Tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.Java:1085) ~[Tomcat-embed-core-9.0.14.jar!/:9.0.14]
        at org.Apache.Tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.Java:1171) ~[Tomcat-embed-core-9.0.14.jar!/:9.0.14]
        at org.Apache.coyote.AbstractProtocol.start(AbstractProtocol.Java:568) ~[Tomcat-embed-core-9.0.14.jar!/:9.0.14]
        at org.Apache.catalina.connector.Connector.startInternal(Connector.Java:1001) ~[Tomcat-embed-core-9.0.14.jar!/:9.0.14]
        ... 22 common frames omitted

2019-01-21 16:02:58.282  INFO 8158 --- [           main] o.Apache.catalina.core.StandardService   : Stopping service [Tomcat]
2019-01-21 16:02:58.292  INFO 8158 --- [           main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-01-21 16:02:58.293 ERROR 8158 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   :

***************************
APPLICATION FAILED TO START
***************************

Description:

The Tomcat connector configured to listen on port 80 failed to start. The port may already be in use or the connector may be misconfigured.

Action:

Verify the connector's configuration, identify and stop any process that's listening on port 80, or configure this application to listen on another port.

2019-01-21 16:02:58.296  INFO 8158 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
1
John Shim

1024未満のポートは、rootユーザーのみに制限されています。 jarをrootとして実行してみてください。

たとえばTomcatでアプリを実行する場合、Tomcatはポート80を開くためにroot権限が必要です。

1
Zwepp