user11138609
user11138609

Reputation:

Server Health status error for Deployment issue of Java Sping boot app in AWS

application.properties file

SERVER_PORT = 5000

enter image description here enter image description here

Upvotes: 6

Views: 1773

Answers (3)

mylnz
mylnz

Reputation: 414

if your jar file was packaged as executable, edit pom file like this.

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
<!--                <configuration>-->
<!--                    <executable>true</executable>-->
<!--                </configuration>-->
            </plugin>

Upvotes: 4

matesio
matesio

Reputation: 1604

NGINX is not able to connect to your application and health check URL is not getting the required response, due to which your environment status is not changing to GREEN.

/var/log/nginx/access.log

159.192.220.120 - - [01/Apr/2019:15:05:39 +0000] "GET / HTTP/1.1" 502 575 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36" "-"

Check for more logs in

/var/logs/web-1.error.log

you will see something like corrupt/invalid application.jar.

If navigate to /var/app/current directory on your instance you will see two files there

  1. Procfile
  2. application.jar

If you dig more into application.jar using

unzip -lv application.jar

you will find your complete code base there, which shouldn't be. As a result, elastic beanstalk is treating your resultant jar file as a corrupt file. I would recommend you to generate jar file on your local system using mvn, and upload target/StudenCours*.jar file rather than a complete zip bundle to the elastic beanstalk, Also please don't forget to add your main classpath in your manifest file.

Upvotes: 0

stacker
stacker

Reputation: 4485

by default, elb uses port 5000 and it's exposed as env variable named PORT, and you need to use it for your application.

SERVER_PORT is an elb param not for spring boot.

put server.port=${PORT} in your application.properties.

or you can define your own port by setting:

server.port=8001

and then do

eb setenv SERVER_PORT=8001

using AWS CLI

Upvotes: 4

Related Questions