Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 嵌入式Tomcat赢得';t在AWS Elastic Beanstalk中侦听端口80_Java_Amazon Web Services_Tomcat_Spring Boot_Amazon Elastic Beanstalk - Fatal编程技术网

Java 嵌入式Tomcat赢得';t在AWS Elastic Beanstalk中侦听端口80

Java 嵌入式Tomcat赢得';t在AWS Elastic Beanstalk中侦听端口80,java,amazon-web-services,tomcat,spring-boot,amazon-elastic-beanstalk,Java,Amazon Web Services,Tomcat,Spring Boot,Amazon Elastic Beanstalk,我正在向一个Elastic Beanstalk(Java)实例启动一个带有嵌入式Tomcat的Spring Boot.jar 配置文件中的server.port=80,但是EB不会让Tomcat绑定到端口80 是什么阻止Tomcat侦听端口80?如何修复它 以下是日志的相关部分: Caused by: org.apache.catalina.LifecycleException: service.getName(): "Tomcat"; Protocol handler start faile

我正在向一个Elastic Beanstalk(Java)实例启动一个带有嵌入式Tomcat的Spring Boot.jar

配置文件中的server.port=80,但是EB不会让Tomcat绑定到端口80

是什么阻止Tomcat侦听端口80?如何修复它

以下是日志的相关部分:

Caused by: org.apache.catalina.LifecycleException: service.getName(): "Tomcat";  Protocol handler start failed
    at org.apache.catalina.connector.Connector.startInternal(Connector.java:1000) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
    ... 21 common frames omitted
Caused by: java.net.SocketException: Permission denied
    at sun.nio.ch.Net.bind0(Native Method) ~[na:1.8.0_121]
    at sun.nio.ch.Net.bind(Net.java:433) ~[na:1.8.0_121]
    at sun.nio.ch.Net.bind(Net.java:425) ~[na:1.8.0_121]
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) ~[na:1.8.0_121]
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) ~[na:1.8.0_121]
    at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:210) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
    at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:980) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
    at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:573) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
    at org.apache.catalina.connector.Connector.startInternal(Connector.java:993) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
    ... 22 common frames omitted

2017-02-09 09:05:28.126  INFO 2451 --- [           main] o.apache.catalina.core.StandardService   : Stopping service Tomcat
2017-02-09 09:05:28.156  INFO 2451 --- [           main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-02-09 09:05:28.167 ERROR 2451 --- [           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.

2017-02-09 09:05:28.175  INFO 2451 --- [           main] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5387f9e0: startup date [Thu Feb 09 09:05:19 UTC 2017]; root of context hierarchy
2017-02-09 09:05:28.178  INFO 2451 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown

我假设topic starter已经解决了这个问题,但是我会在这里为那些遇到同样问题的新手发布我的解决方案

通过将environment property SERVER_port设置为5000(您可以在“配置”>“软件配置”中进行设置),我已使我的Spring Boot应用程序可以从AWS Elastic Beanstalk上的端口80访问


您可以使用
sudo
运行应用程序,因为
ec2用户不允许绑定到端口80。显然,出于安全考虑,这不是一个好的做法。为什么要在端口80上侦听?默认情况下,Elastic beanstalk将代理端口8080。我以前在使用nodejs时遇到过同样的问题。在beanstalk中,它使用nginx作为代理服务器将http请求传递给NodeJ。