I have a simple Spring Boot application that needs to be plugged into AWS Elastic Beanstalk. An application has one limitation - it must use .jsp templates, therefore, due to the corresponding nuances, it is built in .war , and not in .jar .

If I deploy this application to the pre-built Tomcat environment, everything works fine, but the challenge for me is to put it into the Java environment. After such deployment, the application goes to the Degraded state and 502 responds to an attempt to go through its URL.

I know that nginx listening on port 5000 and installed it in my application.properties . I also found a recommendation to open this port in the env Security group , which I did ( TCP Port 5000 "0.0.0.0/32" ), but it did not help either.

Understanding Amazon’s logs, I didn’t find Tomkat’s start logs, so there may be an error in the corresponding pom.xml dependencies.

Locally everything works well.

Here are my pom.xml dependencies:

  <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> </dependency> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.eclipse.jdt.core.compiler</groupId> <artifactId>ecj</artifactId> <version>4.6.1</version> <scope>provided</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> 

application.properties:

 spring.mvc.view.prefix=/WEB-INF/view/ spring.mvc.view.suffix=.jsp server.port=5000 

Main Java class:

 @SpringBootApplication public class DemowebApplication extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(DemowebApplication.class); } public static void main(String[] args) { SpringApplication.run(DemowebApplication.class, args); } } 

AWS error logs:

 2019/05/07 21:04:45 [error] 7827#0: *19 connect() failed (111: Connection refused) while connecting to upstream, client: 91.232.158.8, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "my-endpoint-tst.us-east-2.elasticbeanstalk.com" 2019/05/07 21:04:46 [error] 7827#0: *19 connect() failed (111: Connection refused) while connecting to upstream, client: 91.232.158.8, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:5000/favicon.ico", host: "my-endpoint-tst.us-east-2.elasticbeanstalk.com", referrer: "my-endpoint-tst.us-east-2.elasticbeanstalk.com/" 

    0