I know, there are a lot of such quesions and answers here, but none of them helped me. I try to install my simple Spring Boot app on AWS Elastic Beanstalk. There is a limitation: it must use .jsp
templates, so it's .war
, not .jar
. If I use predefined Tomcat env on Elastic Beanstalk, everything works fine, but my goal is to use Java env.
When I install my app, its status is getting Degraded
and I become 502 when trying to reach the url.
Locally everything works perfect.
I changed port in application.properties
to 5000, but it didn't help. I found a recommendation to use a security rule for inbound for TCP Port 5000 "0.0.0.0/32"
but it didn't help eather.
Here are my pom.xml
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/"
I suspect that problem is with my Tomcat configuration, but all my experiments with it didn't help yet.